Hi everybody,
Hope you can help me. I have a database to send e-mails from access trough Outlook. The issue is that I would like the body of the e-mail to have hyperlinks, colours, bolds and that I can get it from plain text.
This is the code I have:
How can I make the body to be HTML format, or, can I have a e-mail template storaged in my PC and then indicate to use it whenever the e-mail is sent? Please help me; I have tried to read it and look it over the internet but I need help doing this.
Thanks in advance,
Marina
Hope you can help me. I have a database to send e-mails from access trough Outlook. The issue is that I would like the body of the e-mail to have hyperlinks, colours, bolds and that I can get it from plain text.
This is the code I have:
Code:
Dim MyDB As Database
Dim MyRS As Recordset
Dim MyTable As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim TheAddress As String
Dim TheBody As String
Dim TheCopy As String
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("Sheet2")
MyRS.MoveNext
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
Do Until MyRS.EOF
' Create the e-mail message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
TheAddress = MyRS![Enterprise]
TheBody = "This is a system-generated e-mail, please do not reply. For support please refer to:" & vbNewLine & _
"Dear " & MyRS![First] & "," & "it has come to our attention that you have" & vbNewLine & _
"Should you have another further inquiries, please do not hesitate to contact us" & vbNewLine & _
" " & vbNewLine & _
"People Mobility"
TheCopy = MyRS![ProjectManager]
With objOutlookMsg
' Add the To recipients to the e-mail message.
Set objOutlookRecip = .Recipients.Add(TheAddress)
objOutlookRecip.Type = olBCC
' Set the Subject, the Body, and the Importance of the e-mail message.
.To = MyRS![Enterprise]
.Subject = "Action Required: Please review assignment and/or MyTimeandExpenses information"
.Body = TheBody
.CC = TheCopy & ";" & "dario.a.tejero"
.Importance = olImportanceHigh 'High importance
' Resolve the name of each Recipient.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
MyRS.MoveNext
Loop
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set MyTable = Nothing
End Sub
How can I make the body to be HTML format, or, can I have a e-mail template storaged in my PC and then indicate to use it whenever the e-mail is sent? Please help me; I have tried to read it and look it over the internet but I need help doing this.
Thanks in advance,
Marina