How do I send a HTML formatted e-mail from Access through Lotus No

A

Adam Thwaites

I've used the readily available code from the internet to send out e-mails
from Access through Lotus Notes. Currently the message is sent from my forms
as a string so I cannot add HTML formatting to it. Does anyone know how I
might achieve passing HTML to the e-mail instead?

I use this line to call the following module code:

Call CreateMailandAttachFileAdr(Nz(txtSubject, ""), txtTo, Nz(txtCC, ""),
Nz(txtBCC, ""), txtIsFrom, txtSendingEmailAddress, txtMessage,
Nz(txtAttachment1, ""), Nz(txtAttachment2, ""), chkSaveOnSend, , chkEdit, ,
"")


Here is the module code for sending the e-mail:

Sub CreateMailandAttachFileAdr(Optional IsSubject As String = "", _
Optional SendTo As String = "", Optional CCToAdr As String = "", Optional _
BCCToAdr As String = "", Optional IsFrom As String = "", _
Optional SendingEmailAddress As String = "", Optional IsBody As String,
Optional _
Attach1 As String = "", Optional Attach2 As String = "", Optional SaveOnSend
As String = "", _
Optional MailDB As String = "", Optional edit As Boolean = True, _
Optional Servr As String = "", Optional Acct As String = "")

Const EMBED_ATTACHMENT As Integer = 1454
Const EMBED_OBJECT As Integer = 1453
Const EMBED_OBJECTLINK As Integer = 1452

Dim s As Object ' use back end classes to obtain mail database name
Dim db As Object '
Dim doc As Object ' front end document
Dim beDoc As Object ' back end document
Dim workspace As Object ' use front end classes to display to user
Dim bodypart As Object '

Call CreateNotesSession&(edit)

Set s = CreateObject("Notes.Notessession") 'create notes session
Set db = s.GETDATABASE(Servr, Acct) 'set db to server and file name, if not
'supplied via code will automatically use the default mail db
If db.IsOpen = True Then
Else
Call db.OPENMAIL 'open db to send mail
End If
Set beDoc = db.CREATEDOCUMENT
Set bodypart = beDoc.CREATERICHTEXTITEM("Body")

' Filling the fields
'###################

beDoc.Subject = IsSubject 'Subject line
beDoc.body = IsBody 'Mail message
beDoc.SendTo = SendTo 'To:
beDoc.CopyTo = CCToAdr 'CC:
beDoc.BlindCopyTo = BCCToAdr 'Bcc:
beDoc.From = IsFrom 'Sender's name. May be anything (literally).
'Will show in the "From" field in most email agents
beDoc.PRINCIPAL = SendingEmailAddress 'IsPrincipal 'Sending email address,
must be a valid notes account Name
beDoc.SaveOnSend = SaveOnSend 'tells notes to put message in sent folder


'''''''''''''''''''''''''
''For multiple email addresses you just set beDoc.sendto (or CopyTo or
''BlindCopyTo) to an array of variants each of which will receive the
message.So:

'Dim recip() as variant
'z = item count
'Redim recip(z)
'y = 0
'For i = 0 to ctrl.itemcount
' recip(y) = "emailaddress1"
' y = y + 1
'next i

'beDoc.sendto = recip
''''''''''''''''''''''''

' Attaches I
'###########
' Call bodypart.EmbedObject(EMBED_ATTACHMENT, "", DirWithPathFileName,
FileName)
If Len(Attach1) > 0 Then
If Len(Dir(Attach1)) > 0 Then
Call bodypart.EMBEDOBJECT(EMBED_ATTACHMENT, "", Attach1, Dir(Attach1))
End If
End If

' Attaches II
'############
If Len(Attach2) > 0 Then
If Len(Dir(Attach2)) > 0 Then
Call bodypart.EMBEDOBJECT(EMBED_ATTACHMENT, "", Attach2, Dir(Attach2))
End If
End If

If edit = True Then
Set workspace = CreateObject("Notes.NotesUIWorkspace")
'Position cursor in body of email
Call workspace.EditDocument(True, beDoc).GotoField("Body")
Else
beDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder with current date and time
Call beDoc.Save(True, True)
beDoc.SEND 0, SendTo
End If

Set s = Nothing
Forms![frm_SendEmail]![lblEmailSent].Caption = "Email Sent!"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top