Solved

Formatting Outlook Email in Microsoft Access

Posted on 2014-10-02
8
309 Views
Last Modified: 2014-10-02
I generate an outlook email from MS Access VBA.  The body has one line, but now I need to add a list of items on separate lines.

Equipment
Contract Type

I've tried 2 methods
strBody = "Attached is your quote." & chr(13) & "Equipment" & chr(13) & "Contract Type

strBody = "Attached is your quote." & crlf & "Equipment" & crlf & "Contract Type"

In both methods, the words run together - they are not on a separate line.  How can pass line breaks from access to outlook?

Here is my code to send an outlook email from access
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then 'Already open for mail
    Else
       Maildb.OPENMAIL
End If
       
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = "Marilyn.Columbos@biomerieux.com"
MailDoc.Subject = Subject
MailDoc.Body = strBody
MailDoc.SAVEMESSAGEONSEND = SaveIt
   
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
        MailDoc.CREATERICHTEXTITEM ("Attachment")
    End If
   
    'Send the document
   
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, recipient
0
Comment
Question by:Marilync1266
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 10

Expert Comment

by:Gozreh
ID: 40358294
Did you try to use vbNewLine
0
 

Author Comment

by:Marilync1266
ID: 40358313
I'll give that a try.
0
 

Author Comment

by:Marilync1266
ID: 40358322
That did not work.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Norie
ID: 40358325
Eh, that's not Outlook, it's Lotus Notes/Mail.
0
 

Author Comment

by:Marilync1266
ID: 40358333
Doh!  I have 2 routines - 1 for outlook and 1 for notes.  

Public Function Email_Outlook(recipient As String, Subject As String, Attachment As String, BodyText 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 MailOutLook
    .BodyFormat = olFormatRichText
    '.To = Me.Email_Address
    .Subject = Subject
    .HTMLBody = BodyText
    .Attachments.Add (Attachment)
    .Save
End With

End Function
0
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 40358351
you have two options
or use HTMLBody, then you need to write html code <br>
or you need to change to .Body then the chr(13) or the vbNewLine will work.
0
 

Author Comment

by:Marilync1266
ID: 40358364
Thanks!  That worked!
0
 
LVL 34

Expert Comment

by:Norie
ID: 40358429
Not even an assist.:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question