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

How to add CC or BCC in email subroutine.

Status
Not open for further replies.

19511950

Programmer
Apr 4, 2003
46
US
I have sub that send email thru outllok, but can't figure out how to CC or BCC to this sub. Is anyone knows? Please help.

Sub MySendMail(recipient,msg,subject)
Dim objSession, oInbox, colMessages, oMessage, colRecipients

Set objSession = CreateObject("MAPI.Session")
strServer = "CUEXCHANGE"
strMyMailbox = "IUSR"
strProfileInfo = strServer & vbLf & strMyMailbox

objSession.Logon "", "", False, True, 0, True, strProfileInfo

Set oInbox = objSession.Inbox
Set colMessages = oInbox.Messages
Set oMessage = colMessages.Add()
Set colRecipients = oMessage.Recipients

colRecipients.Add recipient
colRecipients.Resolve

oMessage.Subject = subject
oMessage.Text = msg
oMessage.Send

objSession.Logoff
Set objSession = nothing

End Sub
 
You have to set the type of the recipient after you add them, kinda like below:

Set colRecipients = oMessage.Recipients.Add
colRecipients .Name = "Nancy Davolio"
colRecipients .Type = mapiTo
Set colRecipients = oMessage.Recipients.Add
colRecipients .Name = "Andrew Fuller"
colRecipients .Type = mapiCc
Set colRecipients = oMessage.Recipients.Add
colRecipients .Name = "Michael Suyama"
colRecipients .Type = mapiBcc

 
It doesn't work

Named argument not found: 'colRecipients.Type'
 
i think there's uneeded spaces between the words and periods
double check that in the supplied code/your code.

colRecipients<SPACE>.<SPACE>Type = mapiBcc

make sure those spaces are gone

[thumbsup2]DreX
aKa - Robert
 
Syntax error

colRecipients . Type = mapiTo
----------------^
 
*points to post above the syntax error*

remove the spaces

[thumbsup2]DreX
aKa - Robert
 
I did with spaces and without. It doesn't help.
Do you know other way to add CC?
 
also mapiCC and mapiBCC need to be assigned a value, they're not universal constants as far as i know :

'Set Up Pimary Recipient
.RecipType = 1
'Set up the CC line
.RecipType = 2
'Set up the BCC line
.RecipType = 3

so in effect you'll need :
'Set Up Pimary Recipient
mapiTo = 1
'Set up the CC line
mapiCC = 2
'Set up the BCC line
mapiBCC = 3

in order to use the variables for assignment

also seems .type needs to be .reciptype

got this from google "VB MAPI BCC CC"

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top