Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send RTF formatted Email from Access. 2

Status
Not open for further replies.

ThomasLafferty

Instructor
Mar 14, 2005
549
US
Hey everybody -
I am using an Access 2000 form to compose and send an email to Outlook so that I can have a record of it in my db (I use it to report bugs in the database).

Any idea why the message format is plain text even though I have specified rich text format in my code? I checked my default mail format in Outlook, and it's set to rtf. When I compose a new email straight in Outlook, the message is rtf, when I do it from my form, it's plain text. I can edit it, but if it doesn't come up rtf, I know my user won't bother. Any ideas? Here's my code:

Code:
[COLOR=blue]Private Sub[/color] btnSendBugReport_Click()

[COLOR=blue]On Error GoTo[/color] Err_btnSendBugReport_Click

[COLOR=green]'*****VARIABLE DECLARATION*****[/color]
    [COLOR=blue]Dim[/color] strEmailBody [COLOR=blue]As String[/color], strAdminEmail, strSubject

[COLOR=green]'Get body of email text from control on form[/color]
    Me.BugDescription.SetFocus
    strEmailBody = Me.BugDescription.Text

[COLOR=green]'Get current admin email from table[/color]
    strAdminEmail = DLookup("[AdminEmail]", "tblAdminContactInfo")

[COLOR=green]'Set the email subject line[/color]
    strSubject = "RateEngine1.0 Bug Report"

[COLOR=green]'Launch Outloook and send email, allow message edits, dismiss form[/color]
    DoCmd.SendObject acSendNoObject, , acFormatRTF, strAdminEmail, , , strSubject, strEmailBody, True
    DoCmd.Close
    
Exit_btnSendBugReport_Click:
    [COLOR=blue]Exit Sub[/color]

Err_btnSendBugReport_Click:
    MsgBox Err.Description
    [COLOR=blue]Resume[/color] Exit_btnSendBugReport_Click
    
[COLOR=blue]End Sub[/color]

Any suggestions would be appreciated.

Tom

Born once die twice; born twice die once.
 
ThomasLafferty,
The [tt]acFormatRTF[/tt] specifies the format of the object being sent, not the format of the email itself.

You may want to try OLE automation to create the Email, it will give you a lot more control over the format of the message.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thanks CMP!
I was afraid of that... On a related note, am I right in thinking that using by OLE I would also be able to specify the "Importance" of the email?

Thanks again!

Tom

Born once die twice; born twice die once.
 
Have a look at the BodyFormat and Importance properties of the Outlook.MailItem object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks! Anyway to disable the alert about automatically sending email?

Application.DisplayAlerts = False doesn't work..


Tom

Born once die twice; born twice die once.
 
Use the Display method instead of Send

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That was it - you guys rock!

Tom

Born once die twice; born twice die once.
 
For anyone interested - here's the working code.

Code:
Private Sub btnSendBugReport_Click()
On Error GoTo Err_btnSendBugReport_Click
'*****VARIABLE DECLARATION*****
    Dim strEmailBody As String, strAdminEmail, strSubject, msgImportance
    Dim objOutlook As Object, ItmNewEmail As Object 'Outlook.MailItem


'Get body of email text from control on form
    Me.BugDescription.SetFocus
    strEmailBody = Me.BugDescription.Text
    msgImportance = Me.Ranking.Value

'Get current admin email from table
    strAdminEmail = DLookup("[AdminEmail]", "tblAdminContactInfo")

'Set the email subject line
    strSubject = "RateEngine1.0 Bug Report"


'Launch Outloook and send email, allow message edits, dismiss form
Set objOutlook = CreateObject("Outlook.Application")

Set ItmNewEmail = objOutlook.CreateItem(olMailItem)
With ItmNewEmail
     .To = strAdminEmail
     .Subject = strSubject
     .Body = strEmailBody
     .BodyFormat = olFormatRichText
     .Display
     .Importance = msgImportance
End With

    DoCmd.Close
    
Exit_btnSendBugReport_Click:
    Exit Sub

Err_btnSendBugReport_Click:
    MsgBox Err.Description
    Resume Exit_btnSendBugReport_Click
    
End Sub

Born once die twice; born twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top