Highlighted
Absent Member.
Absent Member.
454 views

[archive] Working with Enumerator's in Outlook

[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
0 Likes
8 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook


           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.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

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).
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

seperate the email addresses with ";".
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

This worked great. I had not thought of creating a separate handle when I added a recipient. Thanks so much.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Working with Enumerator's in Outlook

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.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.