Solved

Formatting Outlook Email in Microsoft Access

Posted on 2014-10-02
8
296 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
Comment Utility
Did you try to use vbNewLine
0
 

Author Comment

by:Marilync1266
Comment Utility
I'll give that a try.
0
 

Author Comment

by:Marilync1266
Comment Utility
That did not work.
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Eh, that's not Outlook, it's Lotus Notes/Mail.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Marilync1266
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!  That worked!
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Not even an assist.:)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now