Assign To and CC list while using Redemption.dll library

Status
Not open for further replies.
C

cGFyZXNo

Hi,

I could see that objSafeMailItem.To and objSafeMailItem.CC properties are

read only. Could any one tell me if there is any way to set added or is being

added recipients to To or CC list in below code:

' itm is selected Mail item object

Set objSafeMailItem = CreateObject("Redemption.SafeMailItem")

Set rpl = CreateObject("Redemption.SafeMailItem")

objSafeMailItem.Item = itm

rpl.Item = itm.Forward

' By default all recipients are getting added to To list. I want

some in CC list as well. Is it possible?

rpl.Recipients.Add (objSafeMailItem.Sender.Name)

For Each olkRecipient In objSafeMailItem.Recipients

rpl.Recipients.Add (olkRecipient.Name)

Next

rpl.Recipients.ResolveAll

Thanks,

Paresh
 
It's the same process as when you add a Recipient using the Outlook object

model. Once you get back the SafeRecipient object from the call to

SafeRecipients.Add() you set the Type of the Recipient. You use one of the

OlMailRecipientType enum members: olTo, olCC or olBCC.

"paresh" <paresh> wrote in message

news:FAD5023E-1F8D-46F4-9302-C5BD850E15F0@microsoft.com...
> Hi,

> I could see that objSafeMailItem.To and objSafeMailItem.CC properties are
> read only. Could any one tell me if there is any way to set added or is
> being
> added recipients to To or CC list in below code:

> ' itm is selected Mail item object
> Set objSafeMailItem = CreateObject("Redemption.SafeMailItem")
> Set rpl = CreateObject("Redemption.SafeMailItem")
> objSafeMailItem.Item = itm
> rpl.Item = itm.Forward

> ' By default all recipients are getting added to To list. I want
> some in CC list as well. Is it possible?

> rpl.Recipients.Add (objSafeMailItem.Sender.Name)

> For Each olkRecipient In objSafeMailItem.Recipients
> rpl.Recipients.Add (olkRecipient.Name)
> Next

> rpl.Recipients.ResolveAll

> Thanks,
> Paresh
 
Since only reading of the To property is blocked, SafeMailItem only

implements the read access. Since write access is not blocked, you can use

the original Outlook Object (itm)

Or you can declare objSafeMailItem as a generic Object rather than

Redemption.safeMailItem to force late binding: you won't get the compiler

warning and Redemption will be happy to forward the calls to the properties

and methods that it does not implement to the original object assigned to

the Item property.

Dmitry Streblechenko (MVP)

-

"paresh" <paresh> wrote in message

news:FAD5023E-1F8D-46F4-9302-C5BD850E15F0@microsoft.com...
> Hi,

> I could see that objSafeMailItem.To and objSafeMailItem.CC properties are
> read only. Could any one tell me if there is any way to set added or is
> being
> added recipients to To or CC list in below code:

> ' itm is selected Mail item object
> Set objSafeMailItem = CreateObject("Redemption.SafeMailItem")
> Set rpl = CreateObject("Redemption.SafeMailItem")
> objSafeMailItem.Item = itm
> rpl.Item = itm.Forward

> ' By default all recipients are getting added to To list. I want
> some in CC list as well. Is it possible?

> rpl.Recipients.Add (objSafeMailItem.Sender.Name)

> For Each olkRecipient In objSafeMailItem.Recipients
> rpl.Recipients.Add (olkRecipient.Name)
> Next

> rpl.Recipients.ResolveAll

> Thanks,
> Paresh
 
Dmitry,

I have changed the type of rpl to Object and below did trick. thanks.

rpl.To = objSafeMailItem.To

rpl.CC = objSafeMailItem.CC

rpl.Recipients.ResolveAll

But it is not resolving the recipients now. :-( Any idea?

Thanks,

Paresh

"Dmitry Streblechenko" wrote:


> Since only reading of the To property is blocked, SafeMailItem only
> implements the read access. Since write access is not blocked, you can use
> the original Outlook Object (itm)

> Or you can declare objSafeMailItem as a generic Object rather than
> Redemption.safeMailItem to force late binding: you won't get the compiler
> warning and Redemption will be happy to forward the calls to the properties
> and methods that it does not implement to the original object assigned to
> the Item property.

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "paresh" <paresh> wrote in message
> news:FAD5023E-1F8D-46F4-9302-C5BD850E15F0@microsoft.com...
> > Hi,
> > I could see that objSafeMailItem.To and objSafeMailItem.CC properties are
> > read only. Could any one tell me if there is any way to set added or is
> > being
> > added recipients to To or CC list in below code:
> > ' itm is selected Mail item object
> > Set objSafeMailItem = CreateObject("Redemption.SafeMailItem")
> > Set rpl = CreateObject("Redemption.SafeMailItem")
> > objSafeMailItem.Item = itm
> > rpl.Item = itm.Forward
> > ' By default all recipients are getting added to To list. I want
> > some in CC list as well. Is it possible?
> > rpl.Recipients.Add (objSafeMailItem.Sender.Name)
> > For Each olkRecipient In objSafeMailItem.Recipients
> > rpl.Recipients.Add (olkRecipient.Name)
> > Next
> > rpl.Recipients.ResolveAll
> > Thanks,
> > Paresh


>
 
Ken, this looks great idea. Could you tell me how could I enum rpl.Recipients

and can set the type?

rpl.Recipients.Add (objSafeMailItem.Sender.Name)

For Each olkRecipient In objSafeMailItem.Recipients

rpl.Recipients.Add (olkRecipient.Name)

Next

??? Enume rpl.Recipients

For Each olkRecipient In rpl.Recipients

?? how to set the type

Next

thanks,

Paresh
wrote:


> It's the same process as when you add a Recipient using the Outlook object
> model. Once you get back the SafeRecipient object from the call to
> SafeRecipients.Add() you set the Type of the Recipient. You use one of the
> OlMailRecipientType enum members: olTo, olCC or olBCC.

> >

>

> "paresh" <paresh> wrote in message
> news:FAD5023E-1F8D-46F4-9302-C5BD850E15F0@microsoft.com...
> > Hi,
> > I could see that objSafeMailItem.To and objSafeMailItem.CC properties are
> > read only. Could any one tell me if there is any way to set added or is
> > being
> > added recipients to To or CC list in below code:
> > ' itm is selected Mail item object
> > Set objSafeMailItem = CreateObject("Redemption.SafeMailItem")
> > Set rpl = CreateObject("Redemption.SafeMailItem")
> > objSafeMailItem.Item = itm
> > rpl.Item = itm.Forward
> > ' By default all recipients are getting added to To list. I want
> > some in CC list as well. Is it possible?
> > rpl.Recipients.Add (objSafeMailItem.Sender.Name)
> > For Each olkRecipient In objSafeMailItem.Recipients
> > rpl.Recipients.Add (olkRecipient.Name)
> > Next
> > rpl.Recipients.ResolveAll
> > Thanks,
> > Paresh


>
 
You can use the For...Each loop you show below or you can get the Count of

the original item's Recipients collection and use a standard For...Next

loop. It's like iterating any collection, not rocket science.

To assign the type is totally simple:

oRecip.Type = OlMailRecipientType.olTo ' or olCC or olBCC

"paresh" <paresh> wrote in message

news:E84F349A-0807-4619-A6A7-EE11EA8793CB@microsoft.com...
> Ken, this looks great idea. Could you tell me how could I enum
> rpl.Recipients
> and can set the type?

> rpl.Recipients.Add (objSafeMailItem.Sender.Name)

> For Each olkRecipient In objSafeMailItem.Recipients
> rpl.Recipients.Add (olkRecipient.Name)
> Next

> ??? Enume rpl.Recipients

> For Each olkRecipient In rpl.Recipients
> ?? how to set the type
> Next

> thanks,
> Paresh
 
Thanks Ken, I did below:

For Each olkRecipient In objSafeMailItem.Recipients

olkRecipient.Type = OlMailRecipientType.olCC

rpl.Recipients.Add (olkRecipient.Name)

Next

Still it is adding it To list only all the recipients. Am I doing anything

wrong?

Thanks,

Paresh
wrote:


> You can use the For...Each loop you show below or you can get the Count of
> the original item's Recipients collection and use a standard For...Next
> loop. It's like iterating any collection, not rocket science.

> To assign the type is totally simple:

> oRecip.Type = OlMailRecipientType.olTo ' or olCC or olBCC

> >

>

> "paresh" <paresh> wrote in message
> news:E84F349A-0807-4619-A6A7-EE11EA8793CB@microsoft.com...
> > Ken, this looks great idea. Could you tell me how could I enum
> > rpl.Recipients
> > and can set the type?
> > rpl.Recipients.Add (objSafeMailItem.Sender.Name)
> > For Each olkRecipient In objSafeMailItem.Recipients
> > rpl.Recipients.Add (olkRecipient.Name)
> > Next
> > ??? Enume rpl.Recipients
> > For Each olkRecipient In rpl.Recipients
> > ?? how to set the type
> > Next
> > thanks,
> > Paresh


>
 
You are attempting to change the Type of the original recipients and hoping

they will be that Type when added to a new mail item as recipients, and it

just doesn't work that way.

Any recipient object added to a mail item will be olTo unless you explicitly

set its Type on the new Recipient object.

For Each olkRecipient In objSafeMailItem.Recipients

Set oRecip = rpl.Recipients.Add (olkRecipient.Name)

oRecip.Type = OlMailRecipientType.olCC

Next

You of course would have to declare that oRecip object somewhere prior to

that loop.

"paresh" <paresh> wrote in message

news:54887605-1E4A-4C13-A974-6E30FEA21FA3@microsoft.com...
> Thanks Ken, I did below:

> For Each olkRecipient In objSafeMailItem.Recipients
> olkRecipient.Type = OlMailRecipientType.olCC
> rpl.Recipients.Add (olkRecipient.Name)
> Next

> Still it is adding it To list only all the recipients. Am I doing anything
> wrong?

> Thanks,
> Paresh
 
Thanks Ken, it works absolutely fine. See my below code:

rpl.Recipients.Add (objSafeMailItem.Sender.Name)

For Each olkRecipient In objSafeMailItem.Recipients

Set odRecip = olkRecipient

Set oRecip = rpl.Recipients.Add(olkRecipient.Name)

oRecip.Type = odRecip.Type

Next

rpl.Recipients.ResolveAll

I have only one problem in resolving the email addresses that are outside

our domain. It resolves the our domain address perfectly but it can't if

email address in outside the domain. I think this is happening because I am

using Recipient.Name property. So suppose name="xxx yyy" and oririginal email

id = "xxxyyy@gmail.com" then it keeps "xxx yyy" in the recipients list and

not resoving to original email id.

Could you help me here.

Thanks for being there.

Paresh
wrote:


> You are attempting to change the Type of the original recipients and hoping
> they will be that Type when added to a new mail item as recipients, and it
> just doesn't work that way.

> Any recipient object added to a mail item will be olTo unless you explicitly
> set its Type on the new Recipient object.

> For Each olkRecipient In objSafeMailItem.Recipients
> Set oRecip = rpl.Recipients.Add (olkRecipient.Name)
> oRecip.Type = OlMailRecipientType.olCC
> Next

> You of course would have to declare that oRecip object somewhere prior to
> that loop.

> >

>

> "paresh" <paresh> wrote in message
> news:54887605-1E4A-4C13-A974-6E30FEA21FA3@microsoft.com...
> > Thanks Ken, I did below:
> > For Each olkRecipient In objSafeMailItem.Recipients
> > olkRecipient.Type = OlMailRecipientType.olCC
> > rpl.Recipients.Add (olkRecipient.Name)
> > Next
> > Still it is adding it To list only all the recipients. Am I doing anything
> > wrong?
> > Thanks,
> > Paresh


>
 
Ken, I have changes the Recipient.Name property to Recipient.Address and its

works perfect now.

Thanks.

"paresh" wrote:


> Thanks Ken, it works absolutely fine. See my below code:

> rpl.Recipients.Add (objSafeMailItem.Sender.Name)
> For Each olkRecipient In objSafeMailItem.Recipients
> Set odRecip = olkRecipient
> Set oRecip = rpl.Recipients.Add(olkRecipient.Name)
> oRecip.Type = odRecip.Type
> Next
> rpl.Recipients.ResolveAll

> I have only one problem in resolving the email addresses that are outside
> our domain. It resolves the our domain address perfectly but it can't if
> email address in outside the domain. I think this is happening because I am
> using Recipient.Name property. So suppose name="xxx yyy" and oririginal email
> id = "xxxyyy@gmail.com" then it keeps "xxx yyy" in the recipients list and
> not resoving to original email id.

> Could you help me here.

> Thanks for being there.
> Paresh

> " - " wrote:
>
> > You are attempting to change the Type of the original recipients and hoping
> > they will be that Type when added to a new mail item as recipients, and it
> > just doesn't work that way.
> > Any recipient object added to a mail item will be olTo unless you explicitly
> > set its Type on the new Recipient object.
> > For Each olkRecipient In objSafeMailItem.Recipients
> > Set oRecip = rpl.Recipients.Add (olkRecipient.Name)
> > oRecip.Type = OlMailRecipientType.olCC
> > Next
> > You of course would have to declare that oRecip object somewhere prior to
> > that loop.
> > > >

> >

> > "paresh" <paresh> wrote in message
> > news:54887605-1E4A-4C13-A974-6E30FEA21FA3@microsoft.com...
> > > Thanks Ken, I did below:
> > > > For Each olkRecipient In objSafeMailItem.Recipients
> > > olkRecipient.Type = OlMailRecipientType.olCC
> > > rpl.Recipients.Add (olkRecipient.Name)
> > > Next
> > > > Still it is adding it To list only all the recipients. Am I doing anything
> > > wrong?
> > > > Thanks,
> > > Paresh

> >
 
The name will only resolve correctly for an entry in your GAL or your

Contacts folder. As you found, the Recipient.Address is more universal.

"paresh" <paresh> wrote in message

news:4FEBAA69-2174-416E-B4C6-C1CE0FFB1EFF@microsoft.com...
> Thanks Ken, it works absolutely fine. See my below code:

> rpl.Recipients.Add (objSafeMailItem.Sender.Name)
> For Each olkRecipient In objSafeMailItem.Recipients
> Set odRecip = olkRecipient
> Set oRecip = rpl.Recipients.Add(olkRecipient.Name)
> oRecip.Type = odRecip.Type
> Next
> rpl.Recipients.ResolveAll

> I have only one problem in resolving the email addresses that are outside
> our domain. It resolves the our domain address perfectly but it can't if
> email address in outside the domain. I think this is happening because I
> am
> using Recipient.Name property. So suppose name="xxx yyy" and oririginal
> email
> id = "xxxyyy@gmail.com" then it keeps "xxx yyy" in the recipients list and
> not resoving to original email id.

> Could you help me here.

> Thanks for being there.
> Paresh
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
R Auto Assign Category colours to Incoming Emails based on whom the email is addressed Outlook VBA and Custom Forms 3
R Assign Categories "Round Robin" style but in a shared mailbox but on specific emails only Outlook VBA and Custom Forms 8
P Auto assign shared mailbox Outlook VBA and Custom Forms 1
D Assign categories to outgoing emails Outlook VBA and Custom Forms 0
F How to assign a task to a public task folder? Using Outlook 1
A How to assign the value returned by the regex execute function to a variable? Using Outlook 1
soadfan assign category (VBA) Using Outlook 7
Diane Poremsky Assign one task to several people Using Outlook 0
Diane Poremsky Assign an Email Account to an Outlook Contact Using Outlook 0
E for Mac: Assign Task not available!? Using Outlook 1
E Outlook VBA to print attached Pdf to a fax printer and assign fax number Using Outlook 0
A Assign a unique number to every message I send Using Outlook 0
Z assign unique number email Using Outlook 8
J Assign a signature by external or internal reciepents. Outlook VBA and Custom Forms 1
P VBA to assign category on calendar item does not work ?? why ?? Outlook VBA and Custom Forms 5
S assign task programmatically Outlook VBA and Custom Forms 2
C Cannot assign a task from a public folder? Outlook VBA and Custom Forms 4
C How to assign icon to a button in Outlook Add-in Outlook VBA and Custom Forms 1
farrissf Category list to pick from Outlook VBA and Custom Forms 4
R Outlook 2019 VBA to List Meetings in Rooms Outlook VBA and Custom Forms 0
S Inconsistent view of To-Do List Using Outlook 0
S Different views for To-Do List and To-Do Bar Using Outlook 1
R Adding Userform Dropdown List items from names of subfolders on network drive Outlook VBA and Custom Forms 10
K Daily Task List Minimized Cannot Display Using Outlook 5
S Outlook 2021 Can you make emails from 3 word domains "safe" by entering top 2 word domain into Safe List in Outlook? Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
D VBA code to select a signature from the signatures list Outlook VBA and Custom Forms 3
L Checking Sender Email Address for trusted domain from list on intranet Outlook VBA and Custom Forms 4
NVDon Create new Move To Folder list Outlook VBA and Custom Forms 0
Ken Pascoe Outlook Categories Quick List Using Outlook 0
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
N How do I make Outlook autocomplete addresses from a list of recognised <full_names> only? Using Outlook 2
T Outlook 2010 Tasks are not visible in To Do list Using Outlook 5
C must select message to trigger safe list Using Outlook 3
N contact list seen in Contact folder but knot in Address book or when 'TO' button is clicked in new email Using Outlook 0
V Pin a document to the "Attach file" Recent Documents list Using Outlook 0
T Junk Email does not get added to the Blocked Sender List Using Outlook 0
Witzker print-list-of-outlook-folders with sort posibility Outlook VBA and Custom Forms 7
F Junk Email does not get added to the Blocked Sender List Using Outlook 4
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
E Asking user to select multiple options in a list in an email Outlook VBA and Custom Forms 0
C Why won't Title display in message list? Using Outlook 1
T Increasing the number of items that appear on the Categories list Using Outlook 2
J Edit auto-complete list in Outlook 2016+/365? Using Outlook 0
M Changing the preferred order for "Put this entry in" list for adding new contacts to the Address Book Using Outlook 1
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
Z See "Change View" Drop Down as a List? Using Outlook 1

Similar threads

Back
Top