Solved

Formatting Outlook Email in Microsoft Access

Posted on 2014-10-02
8
305 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
  • 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 33

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 33

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

749 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