PDA

View Full Version : Sending Email With Access Merged Data--Not As An Attachment



outdone
05-02-2005, 04:30 PM
I have set up a routine in Access to open Word, merge the data into a Word document, save the document and send the document in Outlook as the text of the message. My problem is that I am having trouble getting my recipients classified as either the "TO" recipients or the "CC" recipients.

I am using recipients.add to add them to the message, and that works by placing everyine in the TO area of the message. I just can't figure out how to get some of them to the CC area.

Help!!

Totally Outdone.:think:

MOS MASTER
05-03-2005, 11:18 AM
Hi and Welcome to VBAX, :hi:

Well I can't guess what code you are using so I'm not able to advise on how you are doing it.

Instead I'll give you the code that I use to send mail:
Option Explicit
'Make reference to Microsoft Outlook (appversion) Object library
Sub SendEmail()
Dim bRunning As Boolean
Dim oApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error GoTo StartIt

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Save document first", vbExclamation, "Path verification"
Exit Sub
End If

Set oApp = GetObject(Class:="Outlook.Application")

Set oItem = oApp.CreateItem(olMailItem)
With oItem
.To = "me@vbax.com"
.CC = "here@vbax.com;him@vbax.com"
.Subject = "How are you"
.Body = "Test body"
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, _
DisplayName:="attachment"
.Send
' .Display
End With

If bRunning Then
oApp.Quit
End If

Set oItem = Nothing
Set oApp = Nothing
End

StartIt:
If Err <> 0 Then
Set oApp = CreateObject(Class:="Outlook.Application")
bRunning = True
End If
Resume Next
End Sub


See Attached sample! :whistle: