Issues with getting the Sender Name in email

7

78.sergey

Hi

I am developing a plugin using C#, VSTO 2005 and Outlook 2003.

I am trying to get the sender name (or email address) from myItem
object but apparently the value is always null for this. Is this a
known bug or am I doing something wrong in this.

myItem.SenderName or also myItem.SenderAddress

How do i get this?

I really didnt want to go this route - but also tried getting it from
MAPI property - PR_CREATOR_NAME - but that value is also null.

FYI - I am trying to capture this value during the MailItem_ItemSend
event.

Can anybody please give me some pointers as to why this is not
working.

Thanks
 
D

Dmitry Streblechenko

No sender related propeties are set when the ItemSend event fires.
These properties are set by the transport provider after it asynchronously
sends the message.
Items.ItemAdd event on the Sent Items folder (fired after the message is
sent and moved to the Sent Items folder) is the earliest you can access any
sender related properties.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
7

78.sergey

Thanks Dmitry.

If that is the case - then how do i get the sender name in
MailItem_ItemSend. The reason is - there is a requirement where in the
body of the email - I need to add - This email was SentBy -
(e-mail address removed)

As you mentioned - if all that is not available - then there must be
some alternate way to get that info right ?

Thanks
 
D

Dmitry Streblechenko

Yes, don't use the ItemSend event. Items.ItemAdd event on the Sent Items
folder is the way to go.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
7

78.sergey

Dmitry

Totally understand what you have suuggested. But I guess the problem
is a little unique.

In MailItem_ItemSend event - i capture the email and based on the
business requirements - i have to spawn 1 email per recipient.

In those new emails which are created - I need to that add those to
the body of the email. Also the requirement is that new mailitem I
create - i set the following proeprty :
newMailItem.DeleteAfterSubmit = true;

So technically they never show up in the Sent Items.

You think - there are any creative ways to resolve this.

Thanks
 
D

Dmitry Streblechenko

If you are using Outlook 2007, you can read the MailItem.SendUsingAccount
property.
In the previous versions, you can read the named properties that storee the
name and the id of the account selected in the inspector (look at a message
sent using non-default account with OutlookSpy - click IMessage). If thee
properties are not set, assume the default account.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top