Results 1 to 6 of 6
  1. #1
    baronqueefington is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    32

    email body using html format

    Good evening,

    I have been using the code below to generate email from access, I now want to be able to format the email body and it seems I can do this using html tags. I have seen that you can use the .htmlbody syntax but I can't seem to be able to find where to use it my code.

    Private Sub cmdSendAllocationEmail_Click()

    Dim stdocname As String
    Dim stEmail As String
    Dim stSubject As String
    Dim stbody As String
    On Error GoTo ErrorHandler

    If Not IsNull(Me.BIA_Email_Address) Then


    stdocname = ""

    stEmail = ""

    stEmailcc = ""

    stSubject = ""

    stbody = ""


    DoCmd.SetWarnings False
    DoCmd.SendObject acSendNoObject, , , stEmail, stEmailcc, , stSubject, stbody, , False
    DoCmd.SetWarnings True



    Else: MsgBox "Sorry cannot send email"

    End If
    Exit Sub

    ErrorHandler:
    Select Case Err
    Case 2501
    Case Else
    MsgBox Err.Description
    End Select

    End Sub

    Any help would be much appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    stbody = "<b>This is text with bold emphasis by html tag.</b>"

    However, I don't think it will work with SendObject method. Review https://www.accessforums.net/access/...tml-48507.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
    baronqueefington is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    32
    Hmm I see, thank you for the input.

  4. #4
    baronqueefington is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    32
    hello again,

    I have started to look at the outlook.application solution and have this

    Private Sub cmdSendEmail_Click()
    Dim oApp As Outlook.Application
    Dim oMail As MailItem
    Set oApp = CreateObject("Outlook.application")
    Set oMail = oApp.CreateItem(olMailItem)
    oMail.HTMLBody = Me.DOL
    oMail.Subject = "Test Subject"
    oMail.To = Me.BIA_Email_Address
    oMail.Display
    Set oMail = Nothing
    Set oApp = Nothing



    End Sub

    I can't work out how to format the me.items, such as <b>me.testfield</b>

    I will look some more for the correct syntax, but any help would be appreciated.

    Kind regards,

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Concatenate literal text with variables. Testfield is name of textbox on form?

    "<b>" & Me.testfield & "</b>"
    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.

  6. #6
    baronqueefington is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    32
    Thank you! Me.test was just an example not a real field on my database.

    Thank you again.

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

Similar Threads

  1. Sending Reports with email body having HTML
    By CeVaEs_64 in forum Access
    Replies: 28
    Last Post: 11-26-2014, 12:13 PM
  2. Export html to body of email issue
    By mmart33 in forum Reports
    Replies: 3
    Last Post: 02-28-2013, 03:16 PM
  3. Report Sent as HTML Body - multiple pages
    By chris.williams in forum Reports
    Replies: 3
    Last Post: 09-15-2012, 07:18 PM
  4. Replies: 1
    Last Post: 01-24-2012, 08:31 PM
  5. HTML body in Access 2007
    By amangupts in forum Forms
    Replies: 4
    Last Post: 12-19-2011, 05:52 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