使用c#从outlook发送多个嵌入图像

时间:2014-07-28 16:08:25

标签: c# winforms outlook

以下是使用c#

从Outlook发送单个嵌入图像的代码
public void sendEMailThroughOUTLOOK()
{
    try
    {
       Outlook.Application oApp = new Outlook.Application();

        Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

        string imageCid = "image001.jpg@123";
        oMsg.HTMLBody = String.Format("<body><img src=\"cid:{0}\"></body>", imageCid);
        Attachment attachment1 = oMsg.Attachments.Add(@"E:\wallpapers\WRLDMAP.jpg", OlAttachmentType.olEmbeddeditem, null, "img");
        attachment1.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);

                       //Add an attachment.
        String sDisplayName = "MyAttachment";
        int iPosition = (int)oMsg.HTMLBody.Length + 1;
        int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
        //now attached the file

        Outlook.Attachment oAttach = oMsg.Attachments.Add(@"C:\\SampleFile.txt", iAttachType, iPosition, sDisplayName);

        //Subject line
        oMsg.Subject = "Your Subject will go here.";
        // Add a recipient.
        Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
        Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("abc8@in.com");
        oRecip.Resolve();

        oMsg.Send();
        oRecip = null;
        oRecips = null;
        oMsg = null;
        oApp = null;
    }
    catch (System.Exception ex)
    {   }
}

我不知道如何发送多个嵌入图像。 上述代码需要进行哪些修改?

0 个答案:

没有答案