1
votes

I am trying to send an email using a c++application where I loaded MAPI32.dll first and then tried accessing the MAPISendMail with the necessary parameters being passed. When I tried to execute this step it throwing an exception "Access violation..". When I click continue then it throws "MAPI_E_FAILURE" as the error code. But the same piece of code works fine for windows 7 and outlook 2013 environment.

The environment I am using is windows 10 and outlook 2016 and issue exists in this OS with outlook 2016.

I have taken this link as reference:MAPISendMail_Expert

I could not trace out what exactly is the issue. It would be greatly appreciable if any one could help me.

2

2 Answers

0
votes

I found out what is causing issue, it is because the c++ application I have launched is running with admin privileges and the outlook that is running in the background is launched with non-admin privileges.

Then I launched my outlook in admin mode("Run as administrator"), and sent an email from my c++ application and did it successfully.

To brief, both the application should be launched at same privileges i.e. either running both the applications as non-admin or running both of them (C++ app & outlook) as administrator.

-1
votes

I also met this issue, after testing , i found that you should set

_T("SMTP:") + recipient.m_strAddress

https://msdn.microsoft.com/en-us/library/windows/desktop/dd296720(v=vs.85).aspx , pay attention to lpszAddress, the format are FAX:206-555-1212 and SMTP:[email protected] , I have solved this issue by this way.