Rebex.Mail.MailMessage - Save as Outlook message to be sent - From address issue

0 votes
asked Jul 16 by Paul Kemp (250 points)

I have asked this question before for an older version of Rebex.Mail. Back then the provided answer worked, but as of a while ago (unfortunately I don't know since when) it does not seem to work anymore. The previous question can be found here: http://forum.rebex.net/3587/rebex-mail-mailmessage-outlook-message-sent-address-issue

What I want to accomplish is: I want to create and open an Outlook message that can be sent as a different user through Exchange. In the Outlook interface, I want a different address specified in the From field and I want to be able to send the email through Exchange. I am using Outlook 2013 and Exchange 2013.

I have created a simple test project that I have used to try and figure out how I can set the From address in such a way that the message can be sent. Beheer is the display name, TKBUSR990 is the user name and beheer@tkb.nl is the email address. I have tried all versions below and all give me the same error: "You do not have the permission to send the message on behalf of the specified user."

Can you please help?

namespace ConsoleApp4 {
   class Program {
      static void Main(string[] args) {
         var message = new Rebex.Mail.MailMessage();

         //message.From = "beheer@tkb.nl";
         //message.From = "Beheer";
         //message.From = "TKBUSR990";
         //message.From = "Beheer <beheer@tkb.nl>";
         //message.From = "TKBUSR990 <beheer@tkb.nl>";
         //message.From = "Beheer, beheer@tkb.nl";
         message.From = "TKBUSR990, beheer@tkb.nl";

         message.To = "tkb_test@tkb.nl";
         message.Subject = "Test";
         message.BodyHtml = "<p>This is a test.</p>";
         message.Headers.Add("X-Unsent", "1");
         message.Save("C:\\Temp\\Test.msg", Rebex.Mail.MailFormat.OutlookMsg);
         System.Diagnostics.Process.Start("C:\\Temp\\Test.msg");
      }
   }
}
Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Jul 17 by Lukas Matyska (47,890 points)
selected Jul 18 by Paul Kemp
 
Best answer
  1. Can you please verify that you are still able to send the mail 'manually' as before:

    When I remove the pre-filled email address and manually type in the
    exact same address, I am able to send the message, indicating I indeed
    do have permission to send on behalf of it.

  2. Can you please verify that you are able to send the mail using old version of Rebex library. It can be downloaded from https://www.rebex.net/protected/DownloadArchive.aspx
    Back than you probably used version 2012 R3.

  3. If you are able to send the mail manually. Please,
    a. locate the mail in 'Sent Items'
    b. save it to a .msg file
    c. ZIP the .msg file and the original .msg created by your app
    d. send the ZIP file to support@rebex.net for analysis

commented Jul 17 by Paul Kemp (250 points)
1.  I have verified that I am still able to send the mail 'manually' as before.

2. I have also verified that the old version, 2012R3, still works with the following notations:
- message.From = "Beheer";
- message.From = "Beheer, beheer@tkb.nl";

3. I have sent test files generated with both old (2012R3) and our current (2017R6.3) versions. These files all use the format "Beheer, beheer@tkb.nl"

Thank you for your help.
commented Jul 17 by Lukas Matyska (47,890 points)
Thank you for the info and test files.

I compared them and I found that we now add PropertyTag.SentRepresentingEntryId to the output MSG, which is not well formatted in case of non-SMTP address (this is your case).

This was changed in version 2015 R4 after small refactorization. The field is not added if the email address is null. After refactorization the email address is string.Empty, which passed the check for non-null value.

I have fixed the issue. I will send you link to HOTFIX version to your email in a moment.
commented Jul 18 by Paul Kemp (250 points)
I am happy to confirm the HOTFIX version works as expected for both notations:
- message.From = "Beheer";
- message.From = "Beheer, beheer@tkb.nl";

Thank you very much for your swift response and help. Is this a hotfix on the latest release version or 2017R6.3? Is this the version I should use or should I wait for an official release?
commented Jul 18 by Lukas Matyska (47,890 points)
Thank you for your confirmation.

The hotfix is based on the latest version, which is 2018 R2.

You can use this hotfix version in production, this is the only change against base 2018 R2 official version.
commented Jul 18 by Paul Kemp (250 points)
Again, thank you very much for your quick help.
...