Formatting email message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to format an email message coming from Access to Outlook. I'm looking
to make bold, italics, etc.

Is there a code to do this?
 
One alternative is to use HTML format and embed the HTML formatting tags in
the HTML body text. For example:

Public Function CreateEmail()

Dim ol As New Outlook.Application
Dim itm As Outlook.MailItem

Set itm = ol.CreateItem(olMailItem)

itm.To = "(e-mail address removed)"
itm.Subject = "Test Email"
itm.BodyFormat = olFormatHTML
itm.HTMLBody = "<HTML><Body><Font size=22 color=AA0033 Face='Freestyle
Script'><b><i>This is test.</i></b></Font></Body></HTML>"
itm.Save

End Function

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I want to format an email message coming from Access to Outlook. I'm
looking
to make bold, italics, etc.

Is there a code to do this?
 
While the previous code works in Outlook, I have made a couple small
adjustments to the FONT tag. Some HTML parsers require tag attributes to be
enclosed in quotes.

Public Function CreateEmail()

Dim ol As New Outlook.Application
Dim itm As Outlook.MailItem

Set itm = ol.CreateItem(olMailItem)

itm.To = "(e-mail address removed)"
itm.Subject = "Test Email"
itm.BodyFormat = olFormatHTML
itm.HTMLBody = "<HTML><Body><Font size='22' color='#AA0033' Face='Freestyle
Script'><b><i>This is test.</i></b></Font></Body></HTML>"
itm.Save

End Function

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


One alternative is to use HTML format and embed the HTML formatting tags in
the HTML body text. For example:

Public Function CreateEmail()

Dim ol As New Outlook.Application
Dim itm As Outlook.MailItem

Set itm = ol.CreateItem(olMailItem)

itm.To = "(e-mail address removed)"
itm.Subject = "Test Email"
itm.BodyFormat = olFormatHTML
itm.HTMLBody = "<HTML><Body><Font size=22 color=AA0033 Face='Freestyle
Script'><b><i>This is test.</i></b></Font></Body></HTML>"
itm.Save

End Function

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I want to format an email message coming from Access to Outlook. I'm
looking
to make bold, italics, etc.

Is there a code to do this?
 
Thanks for the information, but how do I incorporate that in my code below?
I have indicated in the coding where I would like to have the text bold
and/or bulleted.

Any help would be appreciated.



Private Sub Command45_Click()
'Takes the contents of the fields and put them into variables.
Client = Form.Client
'txtBody = Form.txtBody
txtProducts1 = Form.txtProducts1
txtProducts2 = Form.txtProducts2
txtProducts3 = Form.txtProducts3
txtProducts4 = Form.txtProducts4
txtProducts5 = Form.txtProducts5
'txtbody2 = Form.txtbody2
'txtforceline = Form.forceline
txtMainAddresses = Form.txtMainAddresses
txtCC = Form.txtCC

'Build the body of the E-mail
bodytext = bodytext & "I'm the Vice President of Products" + Chr(13) + Chr(13)


‘THIS IS WHERE I WOULD LIKE TO BEGIN THE BOLD OR BULLETS
bodytext = bodytext & txtProducts1 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts2 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts3 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts4 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts5 + Chr(13) + Chr(13)
‘THIS IS WHERE I WOULD LIKE TO END THE BOLD OR BULLETS

bodytext = bodytext & "We are honored that you allow us to serve you." + Chr
(13) + Chr(13)
bodytext = bodytext & "Thank you for letting us serve you." + Chr(13) + Chr
(13)
bodytext = bodytext & "http://yahoo.com/" + Chr(13) + Chr(13)
bodytext = bodytext & "Signee Name" + Chr(13)
bodytext = bodytext & "Signee Title"

Dim objOutlook As Object
Dim objmailItem As Object

'Create the Outlook object
Set objOutlook = CreateObject("Outlook.Application")

'Access a new mail item
Set objmailItem = objOutlook.CreateItem(olmailItem)

'Do things with the E-mail
With objmailItem
..To = txtMainAddresses
..cc = txtCC
..subject = "Welcome to Our Company"
..Body = bodytext
..display 'Use .Send if you want the message sent instead of display
End With

Set objmailItem = Nothing
Set objOutlook = Nothing


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

Back
Top