开发者

Last recipient set using office interop always ends up in TO field in outlook2010 even if the type is BCC or CC

开发者 https://www.devze.com 2023-01-21 20:41 出处:网络
I am having problems setting the BCC field in Outlook 2010. This is my situation (using Microsoft.Office.Interop.Outlook):

I am having problems setting the BCC field in Outlook 2010. This is my situation (using Microsoft.Office.Interop.Outlook):

string bcc = "example@example.com";
Recipient recipient = mailItem.Recipients.Add(bcc); // Add the recipient address
recipient.Type = (int)OlMailRecipientType.olBCC; // Set the type to BCC
mailItem.Display(false); // Display the email in Outlook
string addedBCC = mailItem.BCC; // Check that the BCC property gets set

This works fine in outlook 2007, but in Outlook 2010 the address appears in the "To" field instead of the "BCC" field. The variable addedBCC contains the same text as bcc. Am I doing something wrong here?


The actual problem was that when adding several recipients with different types, the last recipient added would always end up in th开发者_运维百科e TO field when displaying the compose window in outlook 2010.


I'm doing something very similar in my Outlook 2010 add-in... I did confirm that getting mailItem.BCC will return an empty string, even after adding a BCC recipient. But when the compose window is eventually displayed, the BCC is correctly listed as a recipent in the BCC field. Hope that helps...


I found out what was causing me trouble and it was not exactly the way I described it in my question.

I was not only adding BCC but also CC and TO and I was adding them in the order TO, CC, BCC. When I was trying this out, I only added one address of each type and that led me to believe the BCC would always end up in the TO field, when in fact the issue was that the last address I added to Recipients ended up in the TO field.

This meant that by changing the order in which I added the recipients to add TO last instead of first, addresses added to CC and BCC would end up in the correct fields.

0

精彩评论

暂无评论...
验证码 换一张
取 消