Question

I am trying to send a message using Extended MAPI, but keep getting an E_ACCESSDENIED error. I am using a C# class which invokes a cpp dll. I am able to check mail and delete messages, but not send. Below is the C# I use to create the message:

using (MAPIMessage message = new MAPIMessage())
{
   if (message.Create(this))
   {
      message.SetSender(send.SenderName, send.SenderAddress);
      message.SetSubject(send.Subject);
      message.SetBody(send.Message);
      message.AddRecipient(send.RecipientAddress);
      //  High: Add attachments

      #if DEBUG
      ConfirmMessageCreation(send, message);
      #endif

      Logger.Log("Message created...\nSending message...", Verbose.LogEverything);
      result = message.Send();
   }

       else
          Logger.Log("There was a problem creating the email.", Verbose.LogImportant);
}

The actual cpp that sends the message follows:

BOOL MessageSend(CMAPIMessage* pMessage)
{
    return pMessage->Send();
}

...

BOOL CMAPIMessage::Send()
{
    HRESULT result = Message()->SubmitMessage(0);

    if(Message() && result==S_OK) 
    {
        Close();
        return TRUE;
    }
    return FALSE;
}

Even though I am properly logged in and can check or delete messages, I get an E_ACCESSDENIED error when calling Send(). Any insight into this issue would be greatly appreciated.

Was it helpful?

Solution

The sender related properties need to be removed.

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