Problem Adding Recipients

7

77m.grub

I am creating an Outlook mail item from within Access and am adding 3
recipients. The code below *should* insert strLeaderEmail in the To
field, strApprentice1Email in the CC field, and strApprentice2Email in
the CC field. But what happens in reality--weird-- is this:
strLeaderEmail is in the To field, strApprentice1Email is in the CC
field, and strApprentice2Email is in the TO FIELD. What am I doing
wrong here?? I am using Outlook 2007. Mike

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookAddSig As Outlook.Inspector
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set objOutlookAddSig = objOutlookMsg.GetInspector

With objOutlookMsg

Set objOutlookRecip = .Recipients.Add(strLeaderEmail)
objOutlookRecip.Type = olTo
Set objOutlookRecip = .Recipients.Add(strApprentice1Email)
objOutlookRecip.Type = olCC
Set objOutlookRecip = .Recipients.Add(strApprentice2Email)
objOutlookRecip.Type = olCC

.Subject = "New Member for Your Small Group"
.HTMLBody = stHTMLBody & .HTMLBody
.Importance = olImportanceHigh
.Display
End With
 
J

JP

Hello,
I'm not familiar with OL2007, but I know if you share variables like
this, your results are unpredictable. My advice is to declare 3
variables, objOutlookRecip1, objOutlookRecip2 & objOutlookRecip3 and
use each one separately.


HTH,
JP
 
7

77m.grub

Apparently the issue is with the "Set objOutlookAddSig =
objOutlookMsg.GetInspector" line. If I comment it out, it works
correctly. Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top