I am having the same problem as the below post, which has no resolution to it. I am trying to give our users the ability to populate a document in our Sales Force Automation system by allowing them to select an email from their inbox and then populating the open document with the body of the email. I have attached my code from the action item used to perform this function. One thing that I have noticed is that if the email is just text it will populate into the new document, however if the email contains any richtext formatting (attachments, bolding, bullets, sections, etc.) then the richtext is not populated into the new document.
Code:------------------------------------------
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim newuidoc As NotesUIDocument ' the new instance of the uidoc after the doc
Dim picklist As Variant
Dim docEMail As NotesDocument
Dim docMemo As NotesDocument
Dim nam As NotesName
Dim vMailInfo As Variant
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set docMemo = uidoc.Document
vMailInfo = Evaluate( "@MailDbName" ) ' Get the server name and filename of the mail database
'Select ONE eMail from the Inbox
Set picklist = workspace.PickListCollection( PICKLIST_CUSTOM, False, vMailInfo(0), vMailInfo(1), _
"($Inbox)", "Bring E-Mail From Mail File", "Please select e-mais to populate the current document" )
If picklist.Count = 0 Then
Exit Sub
End If
Set docEMail = picklist.GetNthDocument(1)
If docEMail.HasItem( "Body" ) Then ' Inbox items like mail router notices have no Body field
Dim rtitemA As Variant
Dim rtitemB As Variant
'…set values of docA and docB…
Set rtitemA = docEMail.GetFirstItem( "Body" )
Set rtitemB = docMemo.CreateRichTextItem( "Body" )
Set nam = New NotesName(docEMail.GetItemValue("CopyTo")(0))
If nam.Common <> "" Then
docMemo.Body = "Copy To: " & nam.Common
End If
docMemo.Type = "Received"
Set nam = New NotesName(docEMail.GetItemValue("From")(0))
docMemo.From_1 = nam.Common
docMemo.Received = docEMail.DeliveredDate(0)
docMemo.Subject = docEMail.Subject(0)
docMemo.Form = "Memo"
If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT ) Then
Call rtitemB.AppendRTItem( rtitemA )
End If
Call docMemo.Save( True, True ) ' Save the new document
’ update the backend and refresh the ui so that the user sees the changes made
Print "Refresh Document"
’ set the SaveOptions field so that when the uidoc is closed, the user won’t be asked to save
docMemo.SaveOptions = "0"
’ close the uidoc. It won’t actually happen until the code is finished executing
uiNoteID = docMemo.NoteID
Call uidoc.Close(True)
’ create a new uidoc and open the backend doc that is still in memory with added information
Set docMemo = db.GetdocumentByID(uiNoteID)
Set newuidoc = workspace.EditDocument(True, docMemo)
’ re-associate the variable with the backend doc
’ have to do this because the olduidoc reference was deleted
Set docMemo = newuidoc.Document
’ remove the SaveOptions field so the doc can be saved
Call docMemo.RemoveItem( "SaveOptions" )
Print "Document Refreshed"
End If
Any assistance would be greatly appreciated.