需要准备带有正文的电子邮件,正文将包含图形



我有一个 asp.net MVC 3 Web应用程序,在某些页面中我显示了一个条形图。

现在用户在该页面中询问"mailto"类型的链接,单击该链接时,电子邮件客户端应该打开,其中TO,主题和正文将自动填充,条形图应出现在正文中。

我知道"mailto"有限制,我们可以像下面这样用简单的文本准备正文,但是有什么解决方法可以将图形放在电子邮件正文中吗?

<A HREF="mailto:help@webcodehelpers.com?Subject=Help&Body=Hello%20%22Name%22%0A%0AWe%20are%20very%20happy%20for%20visiting%20our%20website%20webcodehelpers.com%20portal%2C%20which%20is%20providing%20useful%20information%20%2C%20code%20snippets%20and%20live%20examples.%0A%0AWe%20also%20providing%20Interview%20tip%20to%20all%20the%20freshers%20in%20web%20development%20and%20experienced%20people%20also%0A%0A%0AThanks%2C%0AWebCodeHelpers.com%20Team">Check Mail</A>

mailto协议非常有限。您可能需要从服务器发送电子邮件。

  using Microsoft.Office.Interop.Outlook;
public void Sendemail()
    {
        try
        {
            Application oApp = new Application();
            MailItem oMsg = (MailItem)(oApp.CreateItem(OlItemType.olMailItem));
            // Set HTMLBody.
            const string emailSubject = "Auto Generated Email:Graph Screen Shot Update for";
            const string sDisplayName = "MyAttachment";
            const int iPosition = 50; // 
            const int iAttachType = (int)OlAttachmentType.olByValue;
            string htmlStart = "<html><body><h5><Font Color=Purpel>Hi,<br/>Please Find below The screen shot as of " + DateTime.Now + "<br/></h5>";
            string body = string.Empty;
            Microsoft.Office.Interop.Outlook.Attachment oAttach = oMsg.Attachments.Add(@"c:Appsdownload.jpg", iAttachType, iPosition, sDisplayName);
            body += "<img src="cid:" + oAttach.FileName + "" /><br/>";
            string wholeBody = htmlStart + body + "<h5><Font Color=Purpel>Note:Please check the graph.<br/>Regards,<br/>Md. Ajmal<br/><br/></h5></body></html>";
            oMsg.HTMLBody = wholeBody;
            // Set the subject.
            oMsg.Subject = emailSubject;
            //display
            oMsg.Display(oMsg);
            // Clean up.
            oMsg = null;
            oApp = null;
        }
        catch (System.Exception ex)
        {
            throw ex;
        }
    }

最新更新