Results 1 to 8 of 8
  1. #1
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286

    FORMATTING Outlook Email in BODY of Access code

    Hello, i have a button on my form that opens out an outlook email. Ont his part of the code:



    With oMail
    .To = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ;
    '.Body =

    is where i enter what i want the message to display, however i cant get the formatting right. Im using access 97. ive attached a word doc which shows EXACTLY how id like the email to open up with. can anyone help me make it look like that? thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This article has code relevant to Access97 up. It shows using HTML tags so should be possible. http://www.everythingaccess.com/tuto...curity-Warning

    If you need to learn about HTML tags check this site http://www.w3schools.com/html/
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    Quote Originally Posted by June7 View Post
    This article has code relevant to Access97 up. It shows using HTML tags so should be possible. http://www.everythingaccess.com/tuto...curity-Warning

    If you need to learn about HTML tags check this site http://www.w3schools.com/html/

    thanks for sending me the article, i read through it and tried implementing the ".HTMLBody = " but it looks like it doesnt even recognize that, it put everything from that to the end of my html text in red?

    this is what i have and all of it is in red, saying "compile error:expected expression"


    With oMail
    .to = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ;

    .HTMLBody = "<p>Together as a team WE have the ability to integrate our company's strategy of customer focus while providing operational excellence…"</p>

    <p>Metering Supervisors & Crew Leads:</p>

    <p>Please tailboard with your meter technicians the importance of EDS receiving the HHF on the same day it was collected.</p>

    <p>You are listed in this E-Mail because you have HHF requests issued on 9/7/2011 that are due on 9/8/2011.<br />
    Or you may have some that have been dispatched previously but not received by EDS as of the writing of this E-Mail.</p>

    <p><br />
    Please look at the attached list to see the specifics and associated field order information.</p>

    <p>Please work with Dispatch and your crews to make sure the work is dispatched and the file is collected on time and sent in to: EDS Data Acquisition - Electric </p>

    <p>Please remind your technicians to try to fix the problem while they are on site if at all possible to reduce the need for the HHF collections each month.<br />
    (if these are D.A. sites, we have already notified the ESP/MDMA)</p>

    <p>If you need any assistance, please give me a call.</p>

    <p>Thank you,</p>

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The code is in red because it is not built right. Need to enclose each HTML line in quotation marks and use concatenation and line continuation characters as shown in the example. Also need the html and body tags.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    hrmm i put some test stuff in there just to test it. it stopped turning red, but the email opens up with "<html><body>My <b><i>HTML</i></b> message text!</body></html>"


    this is what i have:
    Dim bodystring As String
    bodystring = "<html>" & _
    "<body>" & _
    "My <b><i>HTML</i></b> message text!" & _
    "</body>" & _
    "</html>"


    .body = bodystring

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I just did a simple test sending myself an email with HTML coding. This worked:
    Code:
    Public Sub TestEmail()
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
        .BodyFormat = olFormatRichText
        .To = "email address here"
        ''.cc = ""
        ''.bcc = ""
        .Subject = "HTML TEST"
        .HTMLBody = "<HTML><body>" & _
                    "<font color='red'>This is a test</font>" & _
                    "<body><HTML>" & _
                    Chr(10) & Chr(13) & Now
        ''.Attachments.Add (strZip)
        .DeleteAfterSubmit = True 'to not save in sent bin
        ''.Display
        .Send
    End With
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    thank you, that worked. the only thing is it still shows up on 1 line in my email? do you know of another way to make it so i can put text on the next line?

  8. #8
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    nevermind, was able to figure it out. thanks for your help!...now only if i could figure out that excel problem of pasting my rows in the subform to a spreadsheet...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-23-2011, 08:07 AM
  2. Email from report to Email body
    By Ehmke66 in forum Programming
    Replies: 4
    Last Post: 01-03-2011, 01:06 PM
  3. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 PM
  4. Replies: 3
    Last Post: 09-01-2010, 08:43 PM
  5. Field Name into Subject/Body of an email?
    By Stanggirlie in forum Programming
    Replies: 0
    Last Post: 01-05-2009, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums