Create a mailto command button

  • Thread starter Thread starter RickB
  • Start date Start date
R

RickB

I have a database of contacts. These contacts also have category
designations. I have an unbound form which has the categories listed in a
drop down. I would like to be able to create a command button which would
act like a mailto button but to put all email addresses into the BCC field
of a new email message from the query created by the category drop down on
the unbound form.

Any help would be appreciated.

-rick
 
If you use the SendObject method, you will be able to put the addresses into
the BCC field.

To collect the addresses into a string, you will need code to loop through
the recordset and concatenate the values into the string.
 
Here is a subroutine posted by ahuntertate today in answer to another post:
"Subject: Re: sending email from Access"

If you didn't notice it, this might answer your question, too:

Sub SendMessages(Optional AttachmentPath)

Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim TheAddress As String

Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("tblMailingList")
MyRS.MoveFirst

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the e-mail message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipients to the e-mail message.
==> ' Loop through Recordset here
==> Do Until MyRS.EOF
==> TheAddress = MyRS![EmailAddress]
==> Set objOutlookRecip = .Recipients.Add(TheAddress)
==> objOutlookRecip.Type = olTo
==> MyRS.MoveNext
==> Loop
'********************************************
'Commented Out for Testing without Form
' Add the Cc recipients to the e-mail message.
'If (IsNull(Forms!frmMail!CCAddress)) Then
'Else
' Set objOutlookRecip = .Recipients.Add(Forms!frmMail!CCAddress)
' objOutlookRecip.Type = olCC
'End If

' Set the Subject, the Body, and the Importance of the e-mail message.
.Subject = "TEST Multiple Sends" 'Forms!frmMail!Subject
.Body = " TEST Message" 'Forms!frmMail!MainText
.Importance = olImportanceHigh 'High importance

'Add the attachment to the e-mail message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve the name of each Recipient.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With

Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
 
Back
Top