Search code examples
c#outlook-redemptionmsg

Attaching a msg file to a msg with Redemption


I am working on a proof of concept application, and the end goal is to create a bunch of msg files with attachemnts. So, we have a parent .msg with multiple child .msg files attached. I have managed to create the child msg's fine, but when it comes to creating the parent msg files with the children attached, it just won't work. I am using Redemption for this, and it's the trial version.

  IRDOSession rdoSession = new RDOSession();
  rdoSession.Logon("", "", false, false, null, false);

  IRDOMail m = rdoSession.GetMessageFromMsgFile(@"c:\test\test.msg", true);

  m.Recipients.Add("****");
  m.Recipients.ResolveAll(null, null);
  m.Subject = "Subject of test .msg";
  m.HTMLBody = "<strong>This is a test body</strong>";
  m.SenderEmailAddress = "******";

  m.Attachments.Add(@"C:\test\t.txt", Type.Missing, Type.Missing, Type.Missing);

  m.SaveAs(@"c:\test\test.msg");

Has anyone come across this issue?

Regards, Chris


Solution

  • I got the answer to this from Dmitry via email. I basically needed to call m.Save(); instad of m.SaveAs();

    m.SaveAs(@"c:\test\test.msg");
    

    replaced with...

    m.Save();