|
Utkarsh
Guest
|
Hi All,
I know this topic has been raised http://www.add-in-express.com/forum/read.php?FID=5&TID=10391 but I am still not able to get the right solution. I am getting MAPI initialize error as below.
---- Stack Trace ----
MyAddin.MAPI.MAPIInitialize(lpMapiInit As IntPtr)
MyAddin.DLL: N 00000 (0x0) JIT
MyAddin.AddinModule.GetAddrBook()
AddinModule.cs: line 0263, col 13, IL 0001 (0x1)
MyAddin.AddinModule.GetSMTPAddress(exchangeAddress As String)
AddinModule.cs: line 0180, col 13, IL 0007 (0x7)
MyAddin.AddinModule.GetSMTPEmailAddress(item As MailItem)
AddinModule.cs: line 0146, col 21, IL 0057 (0x39)
MyAddin.AddinModule.Execute()
AddinModule.cs: line 0131, col 21, IL 0071 (0x47)
MyAddin.AddinModule.adxCommandBarButton1_Click(sender As Object)
AddinModule.cs: line 0117, col 13, IL 0007 (0x7)
AddinExpress.MSO.ADXCommandBarButton.OnButtonClick(button As ICommandBarButton, handled As Boolean&)
MyAddin.DLL: N 0065 (0x41) IL
My code can be downloaded from https://www.dropbox.com/s/04wklpdblnvq6ae/MyAddin.zip.
I am using latest version of Add-in express and I want the code to work in all versions from 2003 and above. I have selected the same in ADX wizard.
Kindly let me know what I am doing wrong, so that I can proceed further. An example would be really helpful. |
|
Posted 26 Dec, 2012 09:02:27
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Utkarsh,
Thank you for the code sample. I have just tested your project against Outlook 2010 32-bit with Exchange 2010 account, everything works fine on my side. What error do you get? Which Outlook version do you have installed? |
|
Posted 26 Dec, 2012 09:21:08
|
|
Top
|
|
Utkarsh
Guest
|
Hi Dmitry,
Thanks for your quick response. I have Outlook 2010 64bit.
The code builds fine. However, when I right click on contact in Active Explorer and click the context menu item, it is giving me Unable to find an entry point named 'MAPIInitialize@4' in DLL 'MAPI32.DLL' error.
I have pasted the complete stack trace below now (I did not past last time to reduce the thread side)
Detailed technical information follows:
---
(Inner Exception)
Date and Time: 26 Dec 2012 9:01:10 PM
Machine Name: PC
IP Address:
Current User: PC\Utkarsh
Application Domain: D:\My Development - NoTFS\_OfficeExtensions\MyAddin\bin\Debug\
Assembly Codebase: file:///D:/My Development - NoTFS/_OfficeExtensions/MyAddin/bin/Debug/MyAddin.DLL
Assembly Full Name: MyAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e6d7e281d55d35b
Assembly Version: 1.0.0.0
Exception Source: MyAddin
Exception Type: System.EntryPointNotFoundException
Exception Message: Unable to find an entry point named 'MAPIInitialize@4' in DLL 'MAPI32.DLL'.
Exception Target Site: MAPIInitialize
---- Stack Trace ----
MyAddin.MAPI.MAPIInitialize(lpMapiInit As IntPtr)
MyAddin.DLL: N 00000 (0x0) JIT
MyAddin.AddinModule.GetAddrBook()
AddinModule.cs: line 0263, col 13, IL 0001 (0x1)
MyAddin.AddinModule.GetSMTPAddress(exchangeAddress As String)
AddinModule.cs: line 0180, col 13, IL 0007 (0x7)
MyAddin.AddinModule.GetSMTPEmailAddress(item As MailItem)
AddinModule.cs: line 0146, col 21, IL 0057 (0x39)
MyAddin.AddinModule.Execute()
AddinModule.cs: line 0131, col 21, IL 0071 (0x47)
MyAddin.AddinModule.adxCommandBarButton1_Click(sender As Object)
AddinModule.cs: line 0117, col 13, IL 0007 (0x7)
AddinExpress.MSO.ADXCommandBarButton.OnButtonClick(button As ICommandBarButton, handled As Boolean&)
MyAddin.DLL: N 0065 (0x41) IL
(Outer Exception)
Date and Time: 26 Dec 2012 9:01:10 PM
Machine Name: PC
IP Address: fe80::9588:cb55:4937:b276%11
Current User: PC\Utkarsh
Application Domain: D:\My Development - NoTFS\_OfficeExtensions\MyAddin\bin\Debug\
Assembly Codebase: file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.MSO.2005/7.1.4050.2005__4416dd98f0861965/AddinExpress.MSO.2005.dll
Assembly Full Name: AddinExpress.MSO.2005, Version=7.1.4050.2005, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 7.1.4050.2005
Exception Source:
Exception Type: AddinExpress.MSO.ADXExternalException
Exception Message: An error has occurred in the code of the add-in.
Exception Target Site: Object reference not set to an instance of an object.
---- Stack Trace ---- |
|
Posted 26 Dec, 2012 09:33:57
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
|
Posted 27 Dec, 2012 04:19:13
|
|
Top
|
|
Utkarsh
Guest
|
Hi Dimitry,
I have gone through that blog post and also debugged through the code sample attached in that blog post of yours. However I have few questions regarding the code attached.
1. The code gets either Current user or Recipient email. In my case I need the sender email address.
For example in the attached code in the mentioned blog post, how to get Outlook.AddressEntry object for Sender?
2. Further for Outlook 2010 and less, GetMAPIProp expects MAPIOBJECT parameter from AddressEntry object.
GetMAPIProp(entry.MAPIOBJECT, MAPI.PR_SMTP_ADDRESS);
Please help. Thanks. |
|
Posted 27 Dec, 2012 09:30:23
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Utkarsh,
You can get the AddressEntry object from a Recipient object. Please try to use the code below:
private Outlook.AddressEntry GetAddressEntry(string exchangeAddress)
{
Outlook._NameSpace ns = OutlookApp.GetNamespace("MAPI");
if (ns != null)
try
{
Outlook.Recipient recipient = ns.CreateRecipient(exchangeAddress);
if (recipient != null)
try
{
if (recipient.Resolve())
return recipient.AddressEntry;
}
finally { Marshal.ReleaseComObject(recipient); }
}
finally { Marshal.ReleaseComObject(ns); }
return null;
}
As I mentioned earlier, in Outlook 2010 and 2013 you need to use the Object Model's features rather than Extended MAPI, please see the GetSMTPAddressViaOutlookObjectModel method. |
|
Posted 27 Dec, 2012 09:49:43
|
|
Top
|
|
Utkarsh
Guest
|
Hi Dimitri,
I am able to get the sender email address with the code snippet you provided. Thanks a lot for your attention.
I have one small question though, it takes little over 1 second to get the sender email in SMTP format for one user. Can the performance be improved? If not, can I show progress bar till the time I resolve to SMTP address. My plan is to get the SMTP address for all the mail items in the inbox and in that case I suspect it will be too slow.
Your advice will be helpful. |
|
Posted 27 Dec, 2012 11:23:28
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Utkarsh,
I am glad everything works now.
Can the performance be improved?
You have the entire code and can try to optimize it for your needs. E.g. you can get the _NameSpace object just once and use it when processing mails in the inbox.
If not, can I show progress bar till the time I resolve to SMTP address.
Sure, you can show a form (System.Windows.Forms.Form) with a progress bar. |
|
Posted 28 Dec, 2012 04:15:37
|
|
Top
|
|