?
Solved

Formatting Outlook Email in Microsoft Access

Posted on 2014-10-02
8
Medium Priority
?
312 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

801 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