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
Solved

Formatting Outlook Email in Microsoft Access

Posted on 2014-10-02
8
304 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

860 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