I have VBA code in Microsoft Access that retrieves and sends a specific stationery, however all formatting is lost in the body of the email. Is it possible to retain all formatting (font size, bold text, hyperlinks, etc) when sending the email?
Subject: Please post your code…
Also are the recipients other Notes email users or do they use another email client such as Outlook?
Subject: Here is the code
The recipients are other Notes email users. Here is the code:
Public Function SendNotesMailFromStationery(Password As String, StationeryName As String) As Boolean
Dim Workspace As Object
Dim Session As New NotesSession
Dim Maildb As New NotesDatabase
Dim MailDoc As New NotesDocument
Dim bodytext As New NotesRichTextItem
Dim view As New NotesView
Dim entry As New NotesDocument
Dim MailStationeryName As Variant
SendNotesMailFromStationery = False
'Start a session to notes
Set Session = CreateObject(“Lotus.NotesSession”)
Call Session.Initialize(Password)
'Open the mail database in notes
'Send from TMIG Shared mailbox
Set Maildb = Session.GetDatabase(“servername”, “mail\s3001195”)
If Not Maildb.IsOpen = True Then
Call Maildb.Open
End If
'Create the mail document
Set MailDoc = Maildb.CreateDocument
Call MailDoc.ReplaceItemValue(“Form”, “Memo”)
'Open stationery
Set view = Maildb.GetView(“Stationery”)
Set entry = view.GetFirstDocument
MailStationeryName = entry.GetItemValue(“MailStationeryName”)
Do Until MailStationeryName(0) = StationeryName
Set entry = view.GetNextDocument(entry)
MailStationeryName = entry.GetItemValue("MailStationeryName")
Loop
Call MailDoc.ReplaceItemValue(“Subject”, entry.GetItemValue(“Subject”))
Call MailDoc.ReplaceItemValue(“Body”, entry.GetItemValue(“Body”))
'Set sender and recipients
Call MailDoc.ReplaceItemValue(“Principal”, “emailaddress”)
Call MailDoc.ReplaceItemValue(“SendTo”, entry.GetItemValue(“EnterSendTo”))
Call MailDoc.ReplaceItemValue(“CopyTo”, entry.GetItemValue(“EnterCopyTo”))
Call MailDoc.ReplaceItemValue(“BlindCopyTo”, entry.GetItemValue(“EnterBlindCopyTo”))
'Save draft
'Call MailDoc.Save(True, False, False)
'Send document
MailDoc.SaveMessageOnSend = True
Call MailDoc.ReplaceItemValue(“PostedDate”, Now())
Call MailDoc.Send(False)
SendNotesMailFromStationery = True
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set view = Nothing
Set entry = Nothing
Set Session = Nothing
End Function
Subject: This is why…
Call MailDoc.ReplaceItemValue(“Body”, entry.GetItemValue(“Body”))
Check the help for the GetItemValue and ReplaceItemValue methods of the NotesDocument class. As you can see there, you are copying just the text.
If you want to include formatting, you need to copy the RichText item. Use the CopyItem method for this, look at the online help for that method to see an example of how to copy a rich text field.
See how much easier/faster it is to solve your problem when you actually post your code? ![]()
Subject: Thank you!
The CopyItem method works perfectly. Thank you!