Question

I need to send some eMails from an excel-sheet. I currently use Excel2010, but it should also work with 2013. I searched the net for a solution and found a function, which unfortunatly doesn't work for me.

Sub SendMail(Recepient As String, Address As String, Subject As String, Contents As String)
  Dim mapi_session As MSMAPI.MAPISession
  Dim mapi_messages As MSMAPI.MAPIMessages
  'Set mapi_session = New MSMAPI.MAPISession
  Set mapi_session = CreateObject("MAPI.Session")

  ...

At line Set mapi_session = New MSMAPI.MAPISession it throws an error, saying "Unable to create object by ActiveX component (I translated from german)". I did some more investigation and came across a thread that suggested to use CreateObject instead, but it still throws the same error. I included the msmapi32.ocx beforehand.

I'm pretty new to VBA - any idea what the problem might be?

Thanks in advance,
Frank

No correct solution

OTHER TIPS

CDO 1.21 (that is what "MAPI.Session" is) is no longer being installed by Outlook. You can download it from https://www.microsoft.com/en-us/download/details.aspx?id=3671, but keep in mind that it is no longer being developed or supported by Microsoft.

What do you do with CDO 1.21? You really need to change your code to use only the Outlook Object Model. You can also use Redemption (I am its author) - it's RDO family of objects is (just like CDO 1.21) an in-proc MAPI wrapper and its RDOSession object is similar to MAPI.Session in CDO 1.21 (but has quite a few extra goodies).

Try Set mapi_session = CreateObject("MSMAPI.MAPISession").

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top