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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email BCC & Body with Hyperlink ?

Status
Not open for further replies.

Y22222

Technical User
Dec 4, 2003
15
0
0
US
Hi,
I'm just interested to find out if it is possible to use Hyperlink in code for inserting BCC address & message body.

Now I'm using:
lblEmail.HyperlinkAddress = "mailto:" & eMail


Thanks

 
Here is an example I came up with:

Application.FollowHyperlink "mailto:joe@example.com?cc=bob@example.com&bcc=john@example.com&subject=Test Email&body=hello", , True


 
JohnLowell, Thank you so much!

Is this method any better or worse than SendObject ?
 
Just had to share this...
It works fine with err handling from null attachments and null CC's in case they want to email without a cc or attach, and im requiring the subj and body.
Make sure you have Outlook and DAO references checked.
It may seem odd to call variables then use the me.name, but it had probs use vars, maybe someone can point out why.
**********
Private Sub sendEmailBtn_Click()
On Error GoTo Err_sendEmail
Dim db As DAO.Database, rst As DAO.Recordset
Dim strBody, subject, email As String
Dim varCC, varAtt As Variant
Dim objOutlook As Object 'Outlook.Application
Dim objEmail As Object 'Outlook.MailItem

email = Me.emailTo
varCC = Me.emailCC
subject = Me.emailSubj
strBody = Me.emailBody
varCC = Me.emailCC
varAtt = Me.Text14

If IsNull(Me.emailSubj) Then
MsgBox "There must be something in the subject line for proper email functionality"
Exit Sub
End If
If IsNull(Me.emailBody) Then
MsgBox "There must be something in the body for proper email functionality"
Exit Sub
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Set db = CurrentDb
Set rst = db.OpenRecordset("tblHistory")
rst.AddNew

rst!HistType = "Email"
rst!HistNotes = Me.emailSubj
rst!HistDetails = strBody
rst!HistDate = Format(Now(), "mm/dd/yyyy")
rst!HistTime = Format(Time(), "hh:mm")
rst!ContactID = Me.ContactID.Value
rst!HistAttachFile = Me.Text14.Value

rst.Update
rst.Close
db.Close

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.to = email
.subject = subject
.Body = strBody
If IsNull(varCC) And IsNull(varAtt) Then
.Send
ElseIf IsNull(varAtt) Then
.CC = varCC
.Send
Else
.Attachments.Add varAtt, olByValue, 1
.Send
End If
End With

Set objEmail = Nothing

'objOutlook.Quit

Forms![Contacts].[subHistory].Requery
DoCmd.Close acForm, Me.Name

Err_sendEmail:
Exit Sub
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top