Scenario:
From an Access-form with selected recordset, a report is filled with data, this is converted via VBA into HTML format and sent with Outlook. The content then appears as HTML in the email-body of the recipient. This contains a link that points to the recordset in this form. So assuming the recipient also has ACCESS and also the exact same database (and same location & content), the link would open his database file when clicked, then open the form, then open that exact record by using the query.
Based on this...
...I added a text field into my report with this content and marked it as a hyperlink:
Click here#C:\MainDatabase.accdb#Query frmForm01
Click the hyperlink in the report works (opens Access & file), the link in the locally stored HTML-tempfile also works.
Problem:
Although the link is sent, also appears in the recipient email-body as link "Click here", but displayed link is not clickable, just blue underlined text!
After a lot of experimenting I found out that it's all Outlook! The link is intact in the Outlook-mail-body preview before sending....it must be an Outlook-setting that converts the link into text during/for sending. In the Outlook menu I have already checked the format settings: convert to HTML is OK!(not plain text). So what else could be the cause??
Would be very grateful for solutions. Thanks!
My code:
Sub CreateHTMLMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim FSO As Object
Dim AttchFile As String, EmailTo As String, strSig As String
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olMailItem)
AttchFile = "C:\AttachmTemp.htm"
EmailTo = "abcd@efgh.com"
DoCmd.OpenReport "NewReport", acViewReport, , "[ID]='" & Me.ID & "'", acHidden
DoCmd.OutputTo acOutputReport, "NewReport", acFormatHTML, AttchFile
Set FSO = CreateObject("Scripting.FileSystemObject")
strSig = FSO.OpenTextFile(AttchFile).ReadAll
With OutMail
.TO = EmailTo
.Subject = "New Message"
.BodyFormat = olFormatHTML
.HTMLBody = strSig
.send
End With
End If
Kill AttchFile
Set OutApp = Nothing
Set OutMail = Nothing
End Sub