A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem Adding Recipients



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 8th 08, 04:00 PM posted to microsoft.public.outlook.program_vba, microsoft.public.outlook
[email protected]
external usenet poster
 
Posts: 4
Default Problem Adding Recipients

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
  #2  
Old January 8th 08, 07:13 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Problem Adding Recipients

Weird is right! Try "Set objOutlookRecip = Nothing" before each Add call.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

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

  #3  
Old January 8th 08, 07:17 PM posted to microsoft.public.outlook.program_vba, microsoft.public.outlook
JP[_3_]
external usenet poster
 
Posts: 201
Default Problem Adding Recipients

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


On Jan 8, 11:00*am, wrote:
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


  #4  
Old January 9th 08, 03:05 PM posted to microsoft.public.outlook.program_vba, microsoft.public.outlook
[email protected]
external usenet poster
 
Posts: 4
Default Problem Adding Recipients

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

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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Adding Recipients [email protected] Outlook - General Queries 2 January 9th 08 03:05 PM
Adding recipients to existing mail Items using Redemption [email protected] Add-ins for Outlook 3 April 27th 07 09:07 PM
reccuring appointments auto adding to recipients ChrisW Outlook - Calandaring 0 February 5th 07 11:45 AM
Question on adding safe recipients Terri Outlook - General Queries 2 September 10th 06 02:59 AM
Adding members to group - some recipients listed twice CCNE Outlook - Using Contacts 2 January 27th 06 05:13 PM


All times are GMT +1. The time now is 10:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.