嵌入式图像的Outlook赎回

时间:2013-09-10 20:14:38

标签: c# outlook outlook-redemption

我使用outlook Redemption dll用c#语言创建Outlook消息模板。

以下是我的代码:

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);

一切正常,图像保存到新位置。但当我检查该消息模板时,我无法在任何地方看到图像。而不是图像,它给了我错误。

enter image description here

更新    我没有嵌入图像,只是想附加这个文件。但是当我打开文件时,我没有看到任何附件。我用OutlookSpy检查Total Attachments,它显示0个附件。我的代码是否因附件错误?

1 个答案:

答案 0 :(得分:1)

我找到了解决方法。我需要两次打电话给会议。第一次将附件保存到我的模板文件,而不是再次创建它的新实例。以下是我的代码:

        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);

这适合我。