Alex Abramov
Posts: 34
Joined: 2006-09-15
|
Hi,
I just installed ADX.NET to replace my existing add-in which was experiencing performance and stability issues.
I am currenlty trying to work around two issues. The main one is getting to Extended MAPI properties, since MS was nice enought to leave them out of OOM.
I am trying to get the senders address. I wrote code based on examples provided in ADX toys, and it doesn't work. ADX toys don't work either, although I have not debugged them to check if it's the same problem. I receive the following error message: "Arithmetic operation resulted in an overflow."
The line that causes the error is this:
sender = Marshal.PtrToStringAnsi(new IntPtr(propValue.Value));
I am using C#/VS2005 for OL2002
Below is my code:
string sender = string.Empty;
if (Item is Outlook.MailItem)
{
IntPtr unk = IntPtr.Zero;
object mapiObject = null;
IntPtr unkObj = IntPtr.Zero;
try
{
mapiObject = (Item as Outlook.MailItem).MAPIOBJECT;
unkObj = Marshal.GetIUnknownForObject(mapiObject);
Guid iMapiProp = new Guid("00020303-0000-0000-C000-000000000046");
Marshal.QueryInterface(unkObj, ref iMapiProp, out unk);
if (unk != IntPtr.Zero)
{
IntPtr pPropValue = IntPtr.Zero;
try
{
myMAPI.HrGetOneProp(unk, myMAPI.PR_BODY, out pPropValue);
myMAPI.SPropValue propValue = (myMAPI.SPropValue)Marshal.PtrToStructure(pPropValue, typeof(myMAPI.SPropValue));
// this causes an error due to an artithmetic overflow
sender = Marshal.PtrToStringAnsi(new IntPtr(propValue.Value));
}
catch( Exception ex )
{
HandleException(ex, "GetMAPIProp");
}
if (pPropValue != IntPtr.Zero)
myMAPI.MAPIFreeBuffer(pPropValue);
}
}
catch (Exception ex)
{
HandleException(ex, "GetSender");
return string.Empty;
}
finally
{
if (unkObj != IntPtr.Zero)
Marshal.Release(unkObj);
if (unk != IntPtr.Zero)
Marshal.Release(unk);
if (mapiObject != null)
Marshal.ReleaseComObject(mapiObject);
}
}
return sender;
Thank you,
Alex
P.S. How do I get to the values stored in the Property Page? |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Alex Abramov
Posts: 34
Joined: 2006-09-15
|
Thanks that worked.
Another question:
If I would like to add a custom control to the project (derived from UserControl) should I give it a GUID and a progID? or just let the registration take care of that?
Thanks. |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Alex.
If you are going to put the user control on the Property page, you don't need to register the control. |
|
Alex Abramov
Posts: 34
Joined: 2006-09-15
|
No, I have two forms in my project, one of them needs to list the attachment and let the user decide how to deal with each one individually (save to disk, delete, or leave as is) and I uses a custom control I created to provide a radio box group. This control is going to be repeated as many times on the form as there are attachments.
Do I need to register the forms, and/or the controls which are used in the forms?
Alex |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Alex, you don't need to register the form. Just use them "as is" in the add-in code. |
|