Is there no way to obtain sender's emailid from outlook calender d

V

viplav

I want to get the sender's emailId.

I am able to read all the data of calender by the below code but not the
sender's emailId.

====================CODE STARTS==================================

using Microsoft.Office.Interop.Outlook;

Microsoft.Office.Interop.Outlook.Application outlook = new Application();
Microsoft.Office.Interop.Outlook.NameSpace oNS = outlook.GetNamespace("MAPI");
oNS.Logon(Missing.Value, Missing.Value, true, true);
string currentUserEmail = oNS.CurrentUser.Address;
string currentUserName = oNS.CurrentUser.Name;
// Get the Calendar folder.
Microsoft.Office.Interop.Outlook.MAPIFolder objMAPIFolder =
oNS.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
//Get the Sent folder
MAPIFolder sentFolder =
oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);
Items sentMailItems = sentFolder.Items;
Items items = objMAPIFolder.Items;

foreach (object item in sentMailItems)
{
if (item is MailItem)
{
MailItem oneMail = item as MailItem;
string mailContent = oneMail.HTMLBody;
//item.sender is not available
}
}

foreach (object item in items)
{
if (item is Microsoft.Office.Interop.Outlook.AppointmentItem)

{
Microsoft.Office.Interop.Outlook.AppointmentItem mitem = item as
Microsoft.Office.Interop.Outlook.AppointmentItem;
string subject = mitem.Subject;
DateTime start = mitem.Start;
DateTime end = mitem.End;
string body = mitem.Body;
string location = mitem.Location;
string entryId = mitem.EntryID;

//sender email id not available
//string senderEmail = mitem.sender;
}
}
oNS.Logoff();

=================CODE ENDS=================================

But in any case whether reading appointments or sent folder emails, I am
unable to obtain the sender's email Id.
does anybody have any solution for this problem ?
 
K

Ken Slovak - [MVP - Outlook]

If you were to look at the Object Browser for those items you'd see that
Sender is not a valid property on the items. That's why that doesn't work.
Try using item.SenderEmailAddress or item.SenderName depending on what you
want.

That will work only for mail items since appointments don't have a sender.
You can use the Organizer property on an appointment.
 
V

viplav

actually i am unable to find any property which can give me the sender's
email id. i have tried every existing properties and searched all the
accessible properties but without any result.
 
S

Sue Mosher [MVP]

What do you mean by "email id" -- the sender's name? Email address? Did you
follow Ken's suggestion of looking at the value of the SenderEmailAddress,
SenderName, and Organizer properties? What Outlook version are you coding
for?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


viplav said:
actually i am unable to find any property which can give me the sender's
email id. i have tried every existing properties and searched all the
accessible properties but without any result.
 
V

viplav

by emailId I mean email address.
I have tried all the stuffs which includes ken's suggestion of trying out
"SenderEmailAddress", "SenderName" and anything else available.
But there seems to no way to get the email address of the sender.

--regards
 
K

Ken Slovak - [MVP - Outlook]

So what do you get when you ask for SenderEmailAddress? That's the property
that returns the sender's email address (obviously), so what is it returning
to you?
 
V

viplav

Nothing.

I am using Microsoft.Office.Interop.Outlook.dll on outlook 2007
the property "SenderEmailAddress" is simply not there. In the snippet that i
gave before(above) the object "mitem" should have given me
mitem.SenderEmailAddress form sender's email address.

Yesterday i tried "OUTLOOK REDEMPTON" from
here(http://www.dimastr.com/redemption/) and that gave me sender's email
address. "OUTLOOK REDEMPTON" provides a number of objects and functions to
work with properties and functionality not exposed through the Outlook object
model.
 
K

Ken Slovak - [MVP - Outlook]

I'm very familiar with Redemption, and it does provide access to properties
not exposed in the Outlook object model, but that's not the case with
MailItem.SenderEmailAddress, which is exposed in the object model.

Open the Outlook VBA project and the Object Browser (Alt+F11, then F2).
Select the Outlook object model in the list of references and select
MailItem. Scroll down to the "s" area of the list and tell me you don't see
SenderEmailAddress. Do the same thing in the Object Browser in VS and that
property is also there. I don't know what interface you're looking at but if
it doesn't have that property it's not the correct interface.
 
Top