Cannot get GetSenderEmailExample working

Add-in Express™ Support Service
That's what is more important than anything else

Cannot get GetSenderEmailExample working
Overflow exeption 
Thomas Grossen


Guest


Hi,

I am trying to run you sample "GetSenderEmailExample", but I get an Overflow exception on getting the senderType:

Marshal.PtrToStringAnsi(new IntPtr(propValue.Value));

The propValue.Value to big.

This is on Office 2000. Any idea?

Thank you,

Thomas.
Posted 19 May, 2006 04:52:43 Top
Thomas Grossen


Guest


Hello again,

I have now tried with Office XP, and have the same problem. Does somebody else experimented the same problem?

Thank you.

Thomas.
Posted 19 May, 2006 09:16:52 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Thomas.

Please try the Marshal.PtrToStringAuto or Marshal.PtrToStringUni methods instead of the Marshal.PtrToStringAnsi one.
Posted 19 May, 2006 12:23:10 Top
Thomas Grossen


Guest


Hi Sergey,

Marshal.PtrToStringAuto and Marshal.PtrToStringUni did not resolve the problem.

red

Is there any other way to get the sender email address for Exhange acounts? I mean on Outlook 2000 and 2002.

Thank you.
Posted 19 May, 2006 13:40:16 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Thomas, I will test the example on our Exchange Server on Monday and will send you a solution.
Posted 19 May, 2006 14:36:29 Top
Thomas Grossen


Guest


Thank you Sergey, have a nice week-end.

Thomas.
Posted 19 May, 2006 14:41:48 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Thomas.

You are right. I get the same issue in Office XP.
Fortunately this issue can be fixed very simple.

Just add the following code wherever you call the Marshal.PtrToStringAnsi method in the example:

propValue.Value &= 0xFFFFFFFF;

E.g
.....
else if (senderType == "EX")
{
pPropValue = IntPtr.Zero;
try
{
MAPI.HrGetOneProp(unk, MAPI.PR_SENDER_NAME, out pPropValue);
MAPI.SPropValue propValue = (MAPI.SPropValue)Marshal.PtrToStructure(pPropValue, typeof(MAPI.SPropValue));
propValue.Value &= 0xFFFFFFFF;
senderEmail = Marshal.PtrToStringAnsi(new IntPtr(propValue.Value));
}
catch
{
}
.....
Posted 22 May, 2006 10:49:31 Top
Thomas Grossen


Guest


Hi Sergey,

Your solution works perfectly; thank you angain for your help!

Thomas.
Posted 22 May, 2006 15:07:55 Top