1

I use outlook Redemption dll for creating outlook message template with c# language.

Below is my code:

RedemptionLoader.DllLocation64Bit = Server.MapPath("~/bin/dlls/Redemption64.dll");
RedemptionLoader.DllLocation32Bit = Server.MapPath("~/bin/dlls/Redemption.dll");

Interop.Redemption.RDOSession session = RedemptionLoader.new_RDOSession();

var msg = session.GetMessageFromMsgFile(templatePath);

msg.Subject = String.Format("Report");

String ImageString = Server.MapPath("~\\FolderName") + "\\" + ImageName;
RDOAttachment Attach = msg.Attachments.Add(ImageString);
Attach.ContentID = "image1";
String htb = "<html><head><title>The Title</title></head><body><h1>This is some text</h1>Image 1<br /><img src=cid:image1><br /></body></html>";

msg.HTMLBody = htb;
msg.Save();
msg.SaveAs(newPath);

Everything work and image is saved to new location. But when i check that message template, i could not see Image anywhere. instead of image it gives me error.

enter image description here

Update Instead of embedded image , I tried just to attach this file. But when I open file I didn't see any attachment. I check Total Attachments with OutlookSpy, It shows me 0 attachment. Does my code wrong for attachment?

4

1 回答 1

2

我找到了解决方案。我需要两次调用会话。第一次将附件保存到我的模板文件中,然后再次创建它的新实例。下面是我的代码:

        RedemptionLoader.DllLocation64Bit = Server.MapPath("~/bin/dlls/Redemption64.dll");
        RedemptionLoader.DllLocation32Bit = Server.MapPath("~/bin/dlls/Redemption.dll");


         Interop.Redemption.RDOSession session1 = RedemptionLoader.new_RDOSession();


        var msg1 = session1.GetMessageFromMsgFile(templatePath);


        msg1.Subject = String.Format("Report");

        String ImageString = Server.MapPath("~\\FolderName") + "\\" + ImageName;
        RDOAttachment Attach = msg1.Attachments.Add(ImageString);
        Attach.ContentID = "image1";
        String htb = "<html><head><title>The Title</title></head><body><h1>This is some text</h1>Image 1<br /><img src=cid:image1><br /></body></html>";

        msg1.HTMLBody = htb;
        msg1.Save();

        Interop.Redemption.RDOSession session = RedemptionLoader.new_RDOSession();


        var msg = session.GetMessageFromMsgFile(templatePath);
        msg.SaveAs(newPath);

这对我有用。

于 2013-09-11T23:11:30.890 回答