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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i create multipule lines in body of html VBA email 1

Status
Not open for further replies.

itsmythg

Technical User
Apr 4, 2001
34
0
0
US
ok I am stuck here and i am sure this is something so simple i am missing it. I would really appreciate some input. I am creating an email i send out of a access database to notify users of acces. I can get it to work with one exception, only get one line of data. i would like to have 2 lines. here is the code i am using,


Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
'With objMail
'Set body format to HTML
'.BodyFormat = olFormatHTML
With MailOutLook
.BodyFormat = olFormatRichText
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.Body = "<HTML><BODY><b><font color=red><font size=6>Please READ all instructions before calling TAC Logon using your Network logon.</BODY></HTML>"
.HTMLBody = "<HTML><BODY><font color=blue><font size=4>You will find a link to the documentation under Web Links once you are logged into the VPN Site. USAIT VPN has been fully tested and will work on any computer running Windows 2000 or XP. MAC Users - If you are running a MAC with a Windows emulator running you should have full functionality, however the VPN administrators are unable to support VPN use via a MAC. All others OS are not considered supported If you have any issues please call TAC @ 480-693-6029 for help. If you send reply to this email with questions someone will get back to you within 48hours. </BODY></HTML>"

If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.Add (Me.Mail_Attachment_Path)
End If
'.DeleteAfterSubmit = True 'This would let Outlook send th note without storing it in your sent bin
.Display
'.send
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
in advance let me say thank you the people on this site are always so helpful.
Roxanne
 


Hi,

Just a shot in the dark, but should this statement not be an HTML property value?
Code:
.BodyFormat = olFormatRichText

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
1. Please use the TGML code tags when posting code. Thanks.

2. "I can get it to work with one exception, only get one line of data. i would like to have 2 lines. "

Easy.

Do it exactly the same way you would with normal HTML tags. A <p> tag works just fine. Put it all together with .BodyHTML. Remove your .Body.
Code:
 .HTMLBody = "<HTML><BODY>" & _
     "[b]<p>[/b]<b><font color=red><font size=6>Please READ all " & _
     "instructions before calling TAC Logon using your " & _
     "Network logon.[b]</p>[/b]" & _
     "<font color=blue><font size=4>" & _
     "You will find a link to the documentation under " & _
     "Web Links once you are logged into the VPN Site. " & _
     "USAIT VPN has been fully tested and will work" & _
     "on any computer running Windows 2000 or XP. " & _
     "MAC Users - If you are running a MAC with a " & _
     "Windows emulator running you should have full " & _
     "functionality, however the VPN administrators are" & _
     " unable to support VPN use via a MAC. All others " & _
     "OS are not considered supported If you have any " & _
     "issues please call TAC @ 480-693-6029 for help.  " & _
     "If you send reply to this email with questions " & _
     "someone will get back to you within 48 hours." & _
     "</BODY></HTML>"

Gerry
 


Gerry said:
Remove your .Body

An out-of-.Body experience for this Friday afternoon.

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip, you are correct in a way. BodyFormat is not needed at all. The fact .BodyHTML has a value automatically makes it HTML format. So the lines .BodyFormat and .Body can be completely removed.

Roxanne, you have:
Code:
Dim mess_body As String
but it is never given a value and used. What is this for?

You could of course give the string variable your text, and then use it.
Code:
Sub yaddaHTML()
   Dim mess_body As String
   Dim appOutLook As Outlook.Application
   Dim MailOutLook As Outlook.MailItem
   Set appOutLook = CreateObject("Outlook.Application")
   Set MailOutLook = appOutLook.CreateItem(olMailItem)

   Set appOutLook = CreateObject("Outlook.Application")
   Set MailOutLook = appOutLook.CreateItem(olMailItem)
mess_body = _
  "<HTML><BODY>" & _
  "<p><b><font color=red><font size=6>Please READ all " & _
  "instructions before calling TAC Logon using your " & _
  "Network logon.</p>" & _
  "<font color=blue><font size=4>" & _
  "You will find a link to the documentation under Web " & _
  "Links once you are logged into the VPN Site. " & _
  "USAIT VPN has been fully tested and will work" & _
  "on any computer running Windows 2000 or XP. " & _
  "MAC Users - If you are running a MAC with a " & _
  "Windows emulator running you should have full " & _
  "functionality, however the VPN administrators are " & _
  "unable to support VPN use via a MAC. All others " & _
  "OS are not considered supported If you have any " & _
  "issues please call TAC @ 480-693-6029 for help.  " & _
  "If you send reply to this email with questions " & _
  "someone will get back to you within 48hours." & _
  "</BODY></HTML>"

   With MailOutLook
      .To = "yadda@blahBlah.com"
      .Subject = "whatever"
      .HTMLBody = mess_body
      .Display
      ' your other stuff
      .Send
   End With

Set MailOutLook = Nothing
Set appOutLook = Nothing

End Sub
Please be careful about properly destroying your objects. If you are done with it, you should Set your application instance = Nothing.

Gerry
 
Darn, I hate it when we mis-cue our jokes. Yes indeed, it is an poor out-of-body experience that does not change one's Outlook.

Gerry
 
You guys are the coolest, THANKS for the help.

 



Darn, I thought I had the last shot! [mad]

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
There is that Texan shootin' off again...

yipee-kiyay!

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top