首页 文章

在 Excel 中创建富文本电子邮件,以动态创建的 RTF 通过 Lotus Notes 7 发送

提问于
浏览
0

我正在尝试以编程方式在 Lotus Notes 7 客户端中生成电子邮件,其中的内容是我专门为要发送的每一封电子邮件在 Excel 中构建的 RTF 代码块。

我能够构建,填充和发送电子邮件。但是正文是我的 RTF 代码的 ascii 文本,而不是我期望的格式化版本。

我感觉是因为我的 emailer 函数(从以前的开发人员继承)正在将其作为纯文本传递。如何将其作为富文本格式传递?

相关的电子邮件程序代码:(邮箱名称是公司特定的,因此已更改)另外,请注意,我希望 RichText 作为正文,而不是附件。

Public Sub SendNotesMail(sSubject, sTo, sCC, sBCC, sAttachment, sMessage, Optional sSaveSent As Boolean = True)

'Set up the objects required for Automation into lotus notes
Dim Maildb                              'The mail database
Dim UserName As String                  'The current users notes name
Dim MailDbName As String                'THe current users notes mail database name
Dim MailDoc                             'The mail document itself
Dim RichTextitem As Object              'The RichText Item
Dim AttachME                            'The sAttachment richtextfile object
Dim Session                             'The notes session
Dim EmbedObj                            'The embedded object (sAttachment)
Dim rAttach() As String
Dim x As Integer

'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
Session.ConvertMime = False

'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = Session.UserName
MailDbName = "XXXXX.nsf"

'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", "XXXXXX.nsf")

' Is Mail file already open?
If Maildb.IsOpen = False Then
    Maildb.OPENMAIL
End If

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.form = "Memo"
MailDoc.sendto = sTo
MailDoc.CopyTo = sCC
MailDoc.BlindCopyTo = sBCC
MailDoc.Subject = sSubject
Set RichTextitem = MailDoc.Createrichtextitem("Body")
Call RichTextitem.appendtext(sMessage)
MailDoc.SaveMessageOnSend = sSaveSent

'Set up the embedded object and Attachment and attach it
If sAttachment <> "" Then
    ParseWords rAttach(), sAttachment, ";"
    For x = 0 To UBound(rAttach) Step 1
        Set AttachME = MailDoc.Createrichtextitem("Attachment")
        Set EmbedObj = AttachME.EmbedObject(1454, "", rAttach(x), "Attachment")
    Next x
End If

'Send the document
MailDoc.SaveMessageOnSend = True
MailDoc.SEND 0, sTo

'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

End Sub

这是我的 RTF 文本的一部分。它不呈现任何内容,这只是为了显示我的意思是文本格式。

{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fbidi \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;}        {\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;}
{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}
{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f39\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f40\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}
{\f42\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f44\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}
{\f46\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f49\fbidi \fswiss\fcharset238\fprq2 Arial CE;}{\f50\fbidi \fswiss\fcharset204\fprq2 Arial Cyr;}
{\f52\fbidi \fswiss\fcharset161\fprq2 Arial Greek;}{\f53\fbidi \fswiss\fcharset162\fprq2 Arial Tur;}{\f54\fbidi \fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f55\fbidi \fswiss\fcharset178\fprq2 Arial (Arabic);}

2 回答

  • 4

    您的 RTF 格式的文本不能与 Lotus Notes 的 RTF 格式一起使用。他们是分开的东西。

    您可以使用 Notes API 创建 RTF。请参阅以 NotesRichTextXXXX 开头的方法。提醒您,这并不简单,不幸的是,没有简单的方法可以将 RTF 转换为 Notes Rich Text。

    add-on 可以帮助您处理 RTF。我没有尝试过,但始终强烈建议您使用:http://www.geniisoft.com/showcase.nsf/MidasLSX

    使用 MIME 类,您可以通过 Notes 发送 HTML 电子邮件,这也许是最好的选择。

  • 1

    您实际上需要将本机 Lotus Notes 方法用于 RichText 字段,并从创建的“ RichtextItem”对象创建 RichText 内容。 sMessage 字段将为纯文本,如果需要,则需要通过 NotesRichTextStyle 对象指定格式。

    R7 的 API 详细信息位于这里这里。编写“样式化” Richtext 时,需要内联处理,即开始添加文本,然后在将其变为粗体之前,获取 notesRichTextStyle 对象,在其上设置属性,然后将其应用于 Richtext 对象,然后编写文本。当您需要再次更改样式时,请重复此过程。此演示用法。 MIDAS Richtext 是一种经过验证的真实产品,它消除了创建 RTF 的麻烦,但是您需要购买执照

    对于附件,您可以使用 RichTextItem 的“ embedObject”方法将文件附加到电子邮件的正文中,就像您在代码示例中已经显示的那样,但是我认为您可以 re-use“ body”的 richtextitem 对象字段,请勿使用“附件”字段。您应该能够通过 Internet 发送电子邮件,并且用户可以在电子邮件中看到附件的位置并将其分离。

    这里是用于在示例中嵌入对象的帮助文档,以防您尚未意识到其功能。 (提供的所有链接都是针对 R7.)

相关问题