发送HTML格式的电子邮件 [英] Send Email in HTML Format

查看:113
本文介绍了发送HTML格式的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们正在使用MAPI从我们的应用程序发送纯文本电子邮件。当用户调用此功能时,我们指定对话框标志,以便电子邮件将显示在他们的电子邮件客户端,然后可以修改它并发送。

At the moment we are using MAPI to send a plain text email from our application. We specify the dialog flag when the user invokes this function, so that the email will appear in their email client and they can then modify it and send it.

我们希望以HTML格式发送邮件。

根据此链接MSDN链接MAPI不适用于此 http://support.microsoft.com/kb/268440

We would like to embelish the email and send it in an HTML format.
According to this link MSDN link MAPI is not sutiable for this http://support.microsoft.com/kb/268440

我看过一篇关于ExpertsExchange的文章,说你可以使用MAPI来做,但是我无法得到这个例子来处理Outlook(未尝试任何其他客户端)

I have seen an article on ExpertsExchange that say you can use MAPI to do it but I can't get the example to work with Outlook (not tried anyother client yet)

procedure ShowMailDlg(ToName,Address,HTMLMessage: string);
var
    li: integer;
    lMessage: TMapiMessage;
    lRecipArray: array of TMapiRecipDesc;
    lREs: DWord;
begin
    SetLength(lRecipArray,1);
    lRecipArray[0].ulRecipClass:=MAPI_TO;
    lRecipArray[0].lpszName:=pChar(ToName);
    lRecipArray[0].lpszAddress:=pChar(Address);
    lMessage.ulReserved:=0;
    lMessage.lpszSubject:=nil;
    lMessage.lpszNoteText:=pChar(HTMLMessage);
    lMessage.lpszMessageType:= nil;//pChar('HTML');
    lMessage.lpszDateReceived:=nil;
    lMessage.lpszConversationID:=nil;
    lMessage.flFlags:=0;
    lMessage.lpOriginator:=nil;
    lMessage.nRecipCount:=length(lRecipArray);
    lMessage.lpRecips:=PMapiRecipDesc(lRecipArray);
    lMessage.nFileCount:=0;
    lMessage.lpFiles:=PMapiFileDesc(nil);
    lRes:=MapiSendMail(0, 0 , lMessage,MAPI_DIALOG, 0);
end;

任何人都有任何想法如何做到这一点。我可能会自动化Outlook,但我想保持它相当独立的电子邮件客户端(因此MAPI)

Anyone have any ideas how I can do this. I could probably automate Outlook but I would like to keep it fairly independant of email client (hence MAPI)

谢谢

更新:感谢大家的建议。该功能的问题不是那么大,所以要求用户配置SMTP详细信息并不是一个选择。我想我们只是坚持纯文本电子邮件。

Update: thanks to everyone for the suggestions. The feature is question is not that heavily used, so asking the user to configure SMTP details is not really an option. I think we will just stick to the plain text email.

谢谢

推荐答案

MAPI不支持HTML格式的邮件。从 Microsoft :扩展消息传递应用程序编程接口(MAPI)不应用于生成HTML-作为替代方案,请考虑使用Microsoft Outlook对象模型,CDONTS,CDOSYS,CDOEX或第三方SMTP控件。

MAPI doesn't support HTML formatted messages. From Microsoft : "Extended Messaging Application Programming Interface (MAPI) should not be used to generate HTML-formatted messages. As an alternative, consider using the Microsoft Outlook Object Model, CDONTS, CDOSYS, CDOEX, or a third-party SMTP control."

我会回覆评论关于通过Indy发送。我发布了一个单位,它可以简单地向Indy发送HTML消息。这里或自由写自己的。如果您真的想使消息可以编辑,请尝试使用WPTools和Indy的组合。 WPTools对HTML标记有很好的支持,然后可以通过Indy发送生成的消息。

I would echo the comments about sending via Indy. I published a unit that works to send HTML messsages with Indy very simply here or feel free to write your own. If you really want to make the messages editable, try a combination of WPTools and Indy. WPTools has good support for HTML markup and then you can send the resulting message via Indy.

我没有任何Synapse的经验,所以我不能说多么容易/ /这是项目。

I don't have any experience with Synapse so I can't say how easy/hard it is with that project.

这篇关于发送HTML格式的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆