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!

HTML Email code using Word VBA

Status
Not open for further replies.

Morrow8825

Programmer
Dec 20, 2007
2
US
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
 
If you're asking for the correct code to produce bullets in HTML, it is a combination of unordered list (ul) and list items inside (li). If you're asking what HTML code for an attachment is, there is no such code. You can only link to non-HTML documents.

However, if you're asking what the VBA code would be to write all this, you're in the wrong place. I suggest you look into forum707.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
I apologize for not making my question more clear. My issue is that I need to include a Word document in this email as an attachment. If I can't do it with HTML code, do you have any other suggestions of how I can do this?
 
This forum only deals with HTML and CSS issues. Try the link in Vragabond's answer forum707.

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top