Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2004, 04:47 PM
Authorized User
 
Join Date: Jan 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML content in Outlook Emails generated by Access

Hi :)

I have had good luck creating a VBA script that creates and sends an email using outlook. I just want to know how to add html tags to this. I tried a few methods I found online but nothing has worked. I think the issue is I don't know the correct reference to add. Here is some code similar to what I'm using.

Private Sub Email_Click()
    Dim db As Database, rec As Recordset
    Dim objoutlook As New Outlook.Application
    Dim objMessage As MailItem
    Dim strsql As String, strOrder As String, stritems As String
    Dim intrecords As Integer, strMessage As String

    Set db = CurrentDb()
    Set rec = db.OpenRecordset("recordset")

    strsql = "SELECT * FROM Table WHERE date = Date()"

    While Not rec.EOF

    strOrder = "Data: " & vbTab & vbTab & vbTab & vbTab & rec("test") & vbCrLf & "test1: " & vbTab & rec("test1") & vbCrLf & _
    "test2: " & vbTab & vbTab & vbTab & vbTab & rec("test2") & vbCrLf & vbCrLf

    strBody = strBody & strOrder

    rec.MoveNext

    strHeader = "This is a test" & vbCrLf & vbCrLf & _
    "Your Data: " & vbCrLf & vbCrLf

    strMessage = strHeader & strBody

    Wend

    Set objMessage = objoutlook.CreateItem(olMailItem)
    With objMessage
        .To = "[email protected]"
        .Subject = "Test"
        .Body = strMessage
        .Send
    End With

    rec.Close
    Set rec = Nothing
    Set objoutlook = Nothing
    Set objMessage = Nothing
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
attach excel content to emails,based on criteria miracles Excel VBA 0 May 21st, 2007 09:45 PM
Reading Emails from outlook using VB.net g_vamsi_krish ASP.NET 1.0 and 1.1 Basics 0 August 2nd, 2006 04:19 AM
HTML emails zarol Pro PHP 1 April 9th, 2006 12:57 PM
setting content type of asp generated xml whyulil Classic ASP XML 0 July 15th, 2005 04:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.