我正在尝试创建一个宏,它将打开一个新的Lotus Notes邮件,附加某些文件并从文具邮件中复制和粘贴正文。
我被困在最后一部分,我必须复制文具邮件的BODY并将其粘贴到我创建的新邮件中。
以下是我尝试过的代码,但只有文件被附加但无法从文具中复制正文
感谢任何帮助........
isattached = False
Application.ScreenUpdating = False
'Start Lotus Notes Session
Set nSession = CreateObject("Notes.NotesSession")
On Error GoTo err_send
Set nMailDb = nSession.GetDatabase("", "mailin/GBG180.nsf")
' Open the Stationery View
Set nView = nMailDb.GetView("Stationery")
Set nWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set nCursor = nView.GetFirstDocument
Do While Not nCursor Is Nothing
' get stationery value
StationeryName = nCursor.GetItemValue("MailStationeryName")(0)
' match form template selection versus stationery
If StationeryName = St_name Then
Set nMailDoc = nMailDb.CreateDocument("Memo")
Set AttachME = nMailDoc.CreateRichTextItem("ATTACHMENT")
'Open the PDF folder and attach the files
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(PdfPath)
For Each objFile In objFolder.Files
Set EmbedObj = AttachME.EmbedObject(1454, "", PdfPath & objFile.Name)
isattached = True
Application.Wait (15)
Next
subjectname = policy_num & "-" & aname & "-FoS Invoice & Wording" & " " & Format(DateValue(Now()), "YYYY") & "- Confidential"
If (isattached) Then
'Set nMailDoc = nWorkspace.EDITDOCUMENT(True, nCursor)
nMailDoc.Subject = subjectname
Else
Set nMailDoc = Nothing
Set AttachME = Nothing
Exit Function
End If
nMailDoc.Save True, True, False
Set nMailDoc = Nothing
Set nCursor = Nothing
GoTo nMail_OK
Else
Set nCursor = nView.GetNextDocument(nCursor)
End If
Loop
答案 0 :(得分:4)
在Domino中有用于存储数据的默认项目名称。邮件中的正文(包含所有附件)始终称为“正文”,而不是“示例”中的“附件”。
您需要替换这些行
Set AttachME = nMailDoc.CreateRichTextItem("ATTACHMENT")
'Open the PDF folder and attach the files
...
与这些
Dim bodyStationary as NotesRichtextItem
'- get the richtext from the stationary
Set bodyStationary = nCursor.GetFirstItem( "Body" )
'- create richtextitem in new document
Set AttachME = nMailDoc.CreateRichTextItem("Body")
'- append the stationary
Call AttachMe.AppendRTItem( bodyStationary )
'- add the attachments
'Open the PDF folder and attach the files
...
如果您想将附件放在静止文本的上方,只需将ForendRTItem移动到Foreach循环下方。
在这种情况下,不要忘记添加Attachme.AddNewline( 2 )
,否则文本将直接跟在附件之后。