Hi,
I've used other threads here to learn how to create Outlook emails and the following is almost working. The "button" is actually an image (which I forgot to rename!) on the detail section of a continuous view form which displays relevant email addresses against data.
When I click it I get an email with the right address and subject line, exactly as I need it, but I also get another blank email. I can't see anything in my code that could be causing this.
Any ideas what's causing this? I've closed/reopened Outlook, and compacted and repaired Access db but it's still happening.
Thanks
I've used other threads here to learn how to create Outlook emails and the following is almost working. The "button" is actually an image (which I forgot to rename!) on the detail section of a continuous view form which displays relevant email addresses against data.
When I click it I get an email with the right address and subject line, exactly as I need it, but I also get another blank email. I can't see anything in my code that could be causing this.
Code:
Private Sub Image29_Click()
'Define variables
Dim strTo As String
Dim strSubject As String
Dim strMessage As String
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
'Assign values to defined variables
strTo = Me.RDC_Email.Value
strSubject = "Quarterly upload feedback report"
strMessage = vbCrLf & vbCrLf & vbCrLf & "This is the text that will appear" & _
vbCrLf & "in the body of the email" & vbCrLf & vbCrLf & _
"For now I have turned this off by commenting out" & vbCrLf & "the relevant line further down."
'Create message
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
'Display the message
With objOutlookMsg
objOutlookMsg.To = strToSQL
objOutlookMsg.Subject = strSubject
' objOutlookMsg.Body = strMessage
objOutlookMsg.BodyFormat = olFormatHTML
objOutlookMsg.Importance = olImportanceNormal
objOutlookMsg.Display
End With
Set objOutlook = Nothing
End Sub
Any ideas what's causing this? I've closed/reopened Outlook, and compacted and repaired Access db but it's still happening.
Thanks