Morrow8825
Programmer
I am creating an email to send to a client using HTML code because the email has bullets in it. I also have a file that I need to send as an attachment. What would the code be for the attachment piece? Here is my code:
Sub To_Client()
Dim MailItem As Object
Dim OlMail As Outlook.MailItem
Dim oapp As Outlook.Application
Dim nspnamespace As Outlook.NameSpace
Set oapp = CreateObject("Outlook.Application")
Set nspnamespace = oapp.GetNamespace("Mapi")
Set OlMail = oapp.CreateItem(0)
Set MailItem = CreateObject("CPIOutLook.SafeMailItem")
MailItem.Item = OlMail
MailItem.To = ClientEmail$
MailItem.Subject = "Blackout Notice for " & planname$ & " " & PlanRef$ & " " & "[S" & PlanRef$ & "-" & AdminExt$ & "]"
MailItem.HTMLBody = "<p style=""font-family: Arial; font-size: 10pt;"">" & _
"Attached is a Blackout Notice that needs to be provided to all participants and beneficiaries of deceased participants.<br/>" & _
"</p>" & _
"<p style=""font-family: Arial; font-size: 10pt;"">" & _
"<p style=""font-family:Arial; font-size: 10pt;""><a href=""File:\\m:\plan\" & PlanRef$ & "\" & "Export\Blackoutnotice.doc"">" & _
"Blackoutnotice.doc</a></p>" & _
"<p style=""font-family:Arial; font-size: 10pt;"">If you have any questions, please contact " & Admin$ & " at (620) 793-8473, ext." & AdminExt$ & _
" or " & LCase(AdminEmail$) & ".</p>"
MailItem.Save 'Need to have this line unrem'd to see attachment for testing
MailItem.Display
' MailItem.Send
MsgBox "An email to the client has been created and is in your Outlook Draft folder.", vbInformation, "Macro 10-672"
Set oapp = Nothing
Set nspnamespace = Nothing
Set MailItem = Nothing
End Sub
Sub To_Client()
Dim MailItem As Object
Dim OlMail As Outlook.MailItem
Dim oapp As Outlook.Application
Dim nspnamespace As Outlook.NameSpace
Set oapp = CreateObject("Outlook.Application")
Set nspnamespace = oapp.GetNamespace("Mapi")
Set OlMail = oapp.CreateItem(0)
Set MailItem = CreateObject("CPIOutLook.SafeMailItem")
MailItem.Item = OlMail
MailItem.To = ClientEmail$
MailItem.Subject = "Blackout Notice for " & planname$ & " " & PlanRef$ & " " & "[S" & PlanRef$ & "-" & AdminExt$ & "]"
MailItem.HTMLBody = "<p style=""font-family: Arial; font-size: 10pt;"">" & _
"Attached is a Blackout Notice that needs to be provided to all participants and beneficiaries of deceased participants.<br/>" & _
"</p>" & _
"<p style=""font-family: Arial; font-size: 10pt;"">" & _
"<p style=""font-family:Arial; font-size: 10pt;""><a href=""File:\\m:\plan\" & PlanRef$ & "\" & "Export\Blackoutnotice.doc"">" & _
"Blackoutnotice.doc</a></p>" & _
"<p style=""font-family:Arial; font-size: 10pt;"">If you have any questions, please contact " & Admin$ & " at (620) 793-8473, ext." & AdminExt$ & _
" or " & LCase(AdminEmail$) & ".</p>"
MailItem.Save 'Need to have this line unrem'd to see attachment for testing
MailItem.Display
' MailItem.Send
MsgBox "An email to the client has been created and is in your Outlook Draft folder.", vbInformation, "Macro 10-672"
Set oapp = Nothing
Set nspnamespace = Nothing
Set MailItem = Nothing
End Sub