Reputation: 717
I am trying to add email addresses to MailItem.To using semicolons. It is currently not appending:
myMailItem.To = myMailItem.To + ";"
If I am able to append, I will be able to add other email addresses.
Please help me in this.
Upvotes: 0
Views: 1903
Reputation: 499302
According to the documentation of the To
property:
This property contains the display names only. The To property corresponds to the MAPI property PidTagDisplayTo. The Recipients collection should be used to modify this property.
You should be adding to the Recipients
property.
myMailItem.Recipients.Add(rec1);
Upvotes: 2
Reputation: 172448
Since To
is just a representation of something that is internally (probably) stored as a list, I guess the To setter removes any trailing semicolons. Thus, add the semicolon together with the mail address you want to add:
myMailItem.To = myMailItem.To + ";" + newAddress;
Or, even, better, do as recommended in the documentation...
To Property
[...] The Recipients collection should be used to modify this property.
...and use the Recipients
property:
myMailItem.Recipients.Add(recipient1);
myMailItem.Recipients.Add(recipient2);
...
Upvotes: 3