With the help of Aspose.Email.MailMessage, we are creating a new email by setting the from address as the shared mailbox and with the help of Microsoft.Office.Interop.Outlook, we are moving it to the user’s draft folder and when we try to send that email we are getting the error message as “You Do not have the permission to send the message on behalf of the specified user.”
If the user’s directly create an email in outlook and changes the from address as shared mailbox. They can send the email without any issues. We have double checked and confirmed that user’s have access to send as the shared mailbox. Could you please help us to fix this?
We have investigated the issue on our end and it doesn’t seems to be issue related with API. Actually, Exchange Server requires ‘Send As’ permissions to send the email message in this case. If you don’t have ‘Send As’ permissions, you can’t send the message.
Thanks for the reply. We do have “Send As” permission in Exchange. If we manually set the from address as the shared mailbox and send it, it works. It is only when Aspose is populating the from address for us.
Here is a workaround:
Click From and remove the shared mailbox address by clicking on the X icon image.png (43.0 KB)
I have observed the issue shared by you. We need to investigate it further and in order to proceed further we need to please share the code snippets for all steps including Interop.Outlook application. Please also share the versions of software along with access to account (if possible).
And, below is the code used to save / move email to draft folder
bool mailItemSavedToDraft = false;
object inspectorObj = this.Context;
if (inspectorObj is Outlook.Inspector)
{
Outlook.Inspector inspector = (Outlook.Inspector)inspectorObj;
try
{
object currentItem = inspector.CurrentItem;
if ((currentItem != null) && (currentItem is Outlook.MailItem))
{
Outlook.MailItem currentMailItem = (Outlook.MailItem)currentItem;
if (currentMailItem.Parent is Outlook.MAPIFolder)
{
Outlook.MAPIFolder folder = (Outlook.MAPIFolder)currentMailItem.Parent;
if (folder.Name == "Drafts")
{
mailItemSavedToDraft = true;
}
}
if (!mailItemSavedToDraft)
{
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Outlook.MAPIFolder targetFolder = oApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);
Outlook.MailItem movedMail = null;
movedMail = currentMailItem.Move(targetFolder) as Outlook.MailItem;
movedMail.Save();
movedMail.Display(false);
}
}
}
catch (Exception ex)
{
}
}
Version of software
1. Aspose.Email - 18.11 (I tried with the latest version 20.5 and the issue still persists)
2. Microsoft.Office.Interop.Outlook - 15.0
3. Exchange 2016
4. Outlook 2013
5. Windows server 2016
Thank you for sharing the requested information. A ticket with ID EMAILNET-39851 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.
We suggest you to use email address for the user who is represented by the sender. I hope this will be helpful.
Aspose.Email.MailMessage mailMessage = new Aspose.Email.MailMessage();
// Contains the email address of the sender
// PidTagOriginalSenderEmailAddress
// https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagoriginalsenderemailaddress-canonical-property
mailMessage.Sender = "sender@domain.com";
// Contains the email address for the messaging user who is represented by the sender
// PidTagSentRepresentingEmailAddress
// https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagsentrepresentingemailaddress-canonical-property
mailMessage.From = "sharedMailbox@domain.com";
// Contains a list of display names for recipients that are to get a reply
// PidTagReplyRecipientNames
// https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagreplyrecipientnames-canonical-property
mailMessage.ReplyToList = "replyTo@domain.com";
mailMessage.Body = "any body";
mailMessage.Subject = "any Subject";
MapiMessage mailOutlookMapiMessage = MapiMessage.FromMailMessage(mailMessage);
mailOutlookMapiMessage.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.