Skip to main content

[archive] Working with Enumerator's in Outlook

  • February 19, 2008
  • 11 replies
  • 0 views

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah

11 replies

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah

           CREATE APPLICATION OF OUTLOOK
                 HANDLE IN OL-HANDLE.
           MODIFY OL-HANDLE CREATEITEM(OlMailItem)
                 GIVING MAIL-HANDLE.
           MODIFY MAIL-HANDLE SUBJECT = "Subject".
           MODIFY MAIL-HANDLE BODY    = "Email Body".
           MODIFY MAIL-HANDLE @TO     = "me@my-address.com".
           MODIFY MAIL-HANDLE @CC     = "him@my-address.com".
           MODIFY MAIL-HANDLE @SEND().
           DESTROY OL-HANDLE.


[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah

           CREATE APPLICATION OF OUTLOOK
                 HANDLE IN OL-HANDLE.
           MODIFY OL-HANDLE CREATEITEM(OlMailItem)
                 GIVING MAIL-HANDLE.
           MODIFY MAIL-HANDLE SUBJECT = "Subject".
           MODIFY MAIL-HANDLE BODY    = "Email Body".
           MODIFY MAIL-HANDLE @TO     = "me@my-address.com".
           MODIFY MAIL-HANDLE @CC     = "him@my-address.com".
           MODIFY MAIL-HANDLE @SEND().
           DESTROY OL-HANDLE.


[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
I can do this, the biggest issue is that you can only have one To and one CC recipient this way.

Going through VB, you can use this code:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

To have multiple addresses, you can keep using the .Add method over and over again for new contacts. I can also do this in Cobol, but they all go into the To field. I want to be able to set them in the CC field and can't figure out how to control the type in Cobol as you can in VB.

(Maybe I didn't explain it well enough).

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
Sorry, didn't read the question properly.

Unfortunately I don't know the answer.

Try having a dig around the sample programs on Acucorp's website
I'll also have a look at other samples I've downloaded over time also.

Shaun

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
seperate the email addresses with ";".

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
seperate the email addresses with ";".

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
You are closer to the answer than you think.

77 objOutlookRecip USAGE HANDLE OF RECIPIENT.
...
MODIFY MailItem Recipients::Add ([EMAIL="John@yahoo.com"]John@yahoo.com[/EMAIL]) giving objOutlookRecip.
MODIFY objOutlookRecip @Type = olCC.
MODIFY MailItem Recipients::Add (George[EMAIL="George@yahoo.com"]@yahoo.com[/EMAIL]) giving objOutlookRecip.
MODIFY objOutlookRecip @Type = olCC.
MODIFY MailItem Recipients::Add (Gloria[EMAIL="Gloria@yahoo.com"]@yahoo.com[/EMAIL]) giving objOutlookRecip.
MODIFY objOutlookRecip @Type = olCC.
MODIFY MailItem Recipients::Add (Mary[EMAIL="Mary@yahoo.com"]@yahoo.com[/EMAIL]) giving objOutlookRecip.
MODIFY objOutlookRecip @Type = olCC.


Some may ask if it should not be necessary to DESTROY the objOutlookRecip handle for each, but it is not, because it is just a copy to the reference of the object, not the dispatch itself.

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
This worked great. I had not thought of creating a separate handle when I added a recipient. Thanks so much.

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
The reason that I tend to use the ';' seperated email addresses for multiple recipients or multiple 'CC' or 'BCC' is that I have run into some trouble with setting/adding recipients as described in this post, where outlook has given me error messages relating to 'you are not authorised to send to this recipient'. I never found out why this was but as the ';' seperated option works fine I did not really care.
Keith

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
The reason that I tend to use the ';' seperated email addresses for multiple recipients or multiple 'CC' or 'BCC' is that I have run into some trouble with setting/adding recipients as described in this post, where outlook has given me error messages relating to 'you are not authorised to send to this recipient'. I never found out why this was but as the ';' seperated option works fine I did not really care.
Keith

[Migrated content. Thread originally posted on 18 February 2008]

I have an application that sends emails through Outlook. I now want to add additional recipients that will go in the Cc: list. I cannot figure out how to control where the recipient goes. The example in VB is:

set objOutlookRecip = .Recipients.Add (email address)
objOutlookRecip.Type = olCC

I can get the list of recipients in my RECIPIENTS-HANDLE in my program, but they are all in the To: list, I cannot figure out how to set the type. The .def is:

* OlMailRecipientType
CLASS @OlMailRecipientType
CLSID, 00000000-0000-0000-0000-000000000000
NAME, "OlMailRecipientType"
* "long olOriginator"
ENUMERATOR, @olOriginator, 0
* "long olTo"
ENUMERATOR, @olTo, 1
* "long olCC"
ENUMERATOR, @olCC, 2
* "long olBCC"
ENUMERATOR, @olBCC, 3

I do not know how to use this to modify which recipients I want to add to my message.

TIA,
Rebekah
I will keep that in mind. I have a pretty large group of users using this, and I never know what I will run into with their PC's, security settings, etc. So, you are right, I could have an issue with different users. I will keep that in mind in case someone has problems with the CC addresses.