Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Email in HTML Format

Status
Not open for further replies.

madhouse

Programmer
Sep 17, 2002
165
GB
Within an Access database I've got a procedure that is called at the end of each month for sending an email via Lotus Notes to a group of users. The email basically contains details of any expired libraries that are on our system. However, although the procedure of sending the email via Lotus Notes works fine I can't seem to be able to work out how to use HTML tags to format the email. Is anybody able to shed any light on how this can be done.
Below is the code for the function that sends the email:Function MailExpLibs()

Dim Subject As String
Dim Attachment As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim dbs As Database
Dim Rs As Recordset
Dim Rst As Recordset
Dim CountRs As Integer
Dim CountRst As Integer

'This function will send a mail and attachment if neccessary to the recipient including the body text.
'Requires that notes client is installed on the system.

'Set up the objects required for Automation into lotus notes
Dim Maildb As Object '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 As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)

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

'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 = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"

'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If

'Set the message for the BodyText
BodyText = "Library Control System - Expired Libraries" & vbCrLf & vbCrLf
BodyText = "The following libraries have expired:" & vbCrLf & vbCrLf

Set dbs = CurrentDb

'open recordset to retrieve system names
Set Rs = dbs.OpenRecordset("SELECT * FROM tblSystemName;", dbOpenDynaset)

With Rs
CountRs = Rs.RecordCount
If CountRs > 0 Then .MoveLast
Do While CountRs > 0
''for each system name open a recordset to retrieve the expired library lists


Set Rst = dbs.OpenRecordset("SELECT * FROM tblLibNew WHERE LibStatus = 'E';", dbOpenDynaset)

With Rst
CountRst = Rst.RecordCount
If Count = 0 Then
BodyText = "There are no expired "
If CountRst >= 1 Then
BodyText = BodyText & "CUSV71AA1" & vbCrLf
BodyText = BodyText & "CUSV71AA2" & vbCrLf
BodyText = BodyText & "CUSV71AA3" & vbCrLf
End If
End With

BodyText = BodyText & vbCrLf
BodyText = BodyText & "Open the EMT Library Control Database and take the appropriate action."

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = "someone@xyzcompany.com"
MailDoc.Subject = "Library Control System"
MailDoc.body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt

'Set up the embedded object and attachment and attach it
If Attachment <> &quot;&quot; Then
Set AttachME = MailDoc.CREATERICHTEXTITEM(&quot;Attachment&quot;)
Set EmbedObj = AttachME.EMBEDOBJECT(1454, &quot;&quot;, Attachment, &quot;Attachment&quot;)
MailDoc.CREATERICHTEXTITEM (&quot;Attachment&quot;)
End If

'Send the document
MailDoc.SEND 0, Recipient

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

End Function

 
did you try adding something like so to the body text
BodyText = &quot;<p><font size=&quot;5&quot;>this is BIG text</font></p>&quot;
to see if HTML even will work or not?
DougP, MCP
 
Yes I tried adding standard HTML tags to the BodyText but when I sent a test email to my Lotus Notes email address all the HTML tags were included as part of the message. It seems as though Lotus Notes is unable to recognise the HTML tags and instead just assumes they are part of the message.
I'm wondering whether another parameter or variable has to be set in order for Lotus Notes to know that the email is in HTML format.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top