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

Status
Not open for further replies.
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.

"viplav" <viplav> wrote in message

news:CD45F1DE-C6AC-44C1-A900-1313ACC66FD8@microsoft.com...
> 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 ?
 
V

viplav

Re: Is there no way to obtain sender's emailid from outlook calend

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]

Re: Is there no way to obtain sender's emailid from outlook calend

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

"viplav" <viplav> wrote in message

news:8CD94D51-4223-4902-A173-E73C7AA26FFE@microsoft.com...
> 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.

<kenslovak@mvps.org> wrote in message

news:OkE724dEKHA.4704@TK2MSFTNGP04.phx.gbl...
> 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.

> "viplav" <viplav> wrote in message
> news:CD45F1DE-C6AC-44C1-A900-1313ACC66FD8@microsoft.com...
> >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 ?

>
 
V

viplav

Re: Is there no way to obtain sender's emailid from outlook calend

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]

Re: Is there no way to obtain sender's emailid from outlook calend

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?

"viplav" <viplav> wrote in message

news:32693BFD-5F17-49A1-8879-03C6964B98E0@microsoft.com...

> 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
 
V

viplav

Re: Is there no way to obtain sender's emailid from outlook calend

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]

Re: Is there no way to obtain sender's emailid from outlook calend

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.

"viplav" <viplav> wrote in message

news:8863CBCA-CE06-46F3-B093-AB918C228519@microsoft.com...
> 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.
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A How to obtain the Distribution List of a Sender Outlook VBA and Custom Forms 4
F Obtain Members of a Distribution List Outlook 2003 c# Outlook VBA and Custom Forms 1
J Using Access to obtain E-mail address Outlook VBA and Custom Forms 5
L How I can obtain the text storage in a textbox in outlook? Outlook VBA and Custom Forms 1
M Obtain property value by name Outlook VBA and Custom Forms 5
L Checking Sender Email Address for trusted domain from list on intranet Outlook VBA and Custom Forms 4
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
R Capture Sender's Display name and Address Outlook VBA and Custom Forms 3
T Junk Email does not get added to the Blocked Sender List Using Outlook 0
M How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
F Junk Email does not get added to the Blocked Sender List Using Outlook 4
U Outlook 2016 Outlook 2016 sender name Using Outlook 1
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1
J Autoreply email recieved from specific sender after deleting some text from body. Using Outlook 0
D Reply with a template loose the sender's embedded image Outlook VBA and Custom Forms 0
J Outlook 2016 How tell Outlook not to trust sender? Using Outlook 1
M Screen Scrape Sender IP Address Outlook VBA and Custom Forms 6
S Meeting Invite arrives from Wrong ("send-as") Sender Using Outlook 1
icacream Rule based on sender / wrong sender sent to folder Using Outlook 7
D Moving Emails Based on Recipient/Sender Outlook VBA and Custom Forms 4
B Looking to filter (or just find/search) for only messages that the sender has sent more than 1 messa Using Outlook 2
I How to display sender's name instead of email address in outlook 2013 message Using Outlook 5
A Sort emails into subfolders based on sender and deleting emails automatically Outlook VBA and Custom Forms 3
C Display Sender As Contact Outlook VBA and Custom Forms 4
Ed Sheehan Unusual behaviour in setting Sender (Outlook 2016) Outlook VBA and Custom Forms 4
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
Q Undisclosed recipients does not include sender Using Outlook 1
M Move new mail to folder based on sender address Outlook VBA and Custom Forms 2
D Inserting sender name and address with vba Outlook VBA and Custom Forms 1
M Blocked Sender List @Domain Not Working Using Outlook 0
P MS OUTLOOK 2013 - Adding Sender on the CC line Using Outlook 5
J Saving attachments from specific sender (phone number) to specific folder on hard drive Using Outlook 3
B Can't expose sender email address when linking outlook to access Using Outlook 3
Diane Poremsky Use VBA to create an Outlook Search Folder for Sender Using Outlook 0
K Extract email to excel from a specific sender Outlook VBA and Custom Forms 3
D Change sender name outlook vba 2010 Custom Userform Outlook VBA and Custom Forms 1
O See recent emails from a sender Using Outlook 2
S announce email sender and subject when new email arrives... Using Outlook 7
K check for sender, follow to my personal adress and delete the sent folder. Outlook VBA and Custom Forms 1
P Mail delivery failed returning message to sender Using Outlook 1
K Outlook moves sender's mail, but there is no rule Using Outlook 0
Diane Poremsky Sort messages by Sender domain Using Outlook 1
B Find related messages to sender Outlook VBA and Custom Forms 7
B Find Related Emails to sender Using Outlook 1
Simon How does the sender/organizer to dictate the color of a meeting invitation. Using Outlook 3
V move emails to windows folder and show sender details Using Outlook 7
L Adding sender's e-mail to global address book DL Outlook VBA and Custom Forms 1

Similar threads

Top