Delphi中的电子邮件程序 [英] Email Program in Delphi
问题描述
我正在delphi 7中构建一个电子邮件发送应用程序。我机器上的默认电子邮件客户端配置了Lotus Notes。
我尝试在应用程序中单击发送按钮时执行shellExecute命令。但是在此ShellExecute中,将带有主题,正文等的莲花注释弹出给用户,然后用户需要单击莲花注释中的发送按钮。
I am building an Email send application in delphi 7. Default email client on my machine is configured with lotus notes. I have tried shellExecute command on 'send' button click in application. But in this ShellExecute pop up the lotus notes to user with subject, body etc and then user needs to click on Send button in lotus notes.
我希望当用户单击我的应用程序的发送按钮时,应该使用Lotus Notes自动发送电子邮件。我们可以使用ShellExecute吗?我也尝试使用Indy组件,但没有获得SMTP详细信息。如何查找SMTP服务器详细信息?
感谢您的帮助
I want when user click on Send button of my application then automatically email should be sent using lotus notes. Can we do this using ShellExecute? I tried using Indy components also but I didn't get the SMTP details. How can I find out SMTP server details? thanks for help
推荐答案
使用Lotus Notes发送电子邮件(即使它看起来对我来说有点过头了)一点),我发现了 此帖子
并尝试将其转换为Delphi代码,但我无法在任何地方对其进行测试,因此无法告诉您是否可行。我把原来的评论留在那里。
For sending e-mails using Lotus Notes (even if it looks for me like an overkill a bit) I found this post
and tried to translate it to Delphi code but I can't test it anywhere, so I can't tell you if this works or not. I have left the original comments in there.
uses
ComObj, StrUtils;
// Public Sub SendNotesMail(Subject as string, attachment as string,
// recipient as string, bodytext as string,saveit as Boolean)
// This public sub will send a mail and attachment if neccessary to the
// recipient including the body text.
// Requires that notes client is installed on the system.
procedure SendNotesMail(const Subject: string; const Attachment: string;
const Recipient: string; const BodyText: string; const SaveIt: Boolean);
var
Maildb: OleVariant; // The mail database
UserName: string; // The current users notes name
MailDbName: string; // The current users notes mail database name
MailDoc: OleVariant; // The mail document itself
AttachME: OleVariant; // The attachment richtextfile object
Session: OleVariant; // The notes session
EmbedObj: OleVariant; // The embedded object (Attachment)
begin
Session := CreateOleObject('Notes.NotesSession');
// Next line only works with 5.x and above. Replace password with your password
Session.Initialize('password');
// Get the sessions username and then calculate the mail file name
// You may or may not need this as for MailDBname with some systems you
// can pass an empty string or using above password you can use other mailboxes.
UserName := Session.UserName;
MailDbName := LeftStr(UserName, 1) + RightStr(UserName, (Length(UserName) - Pos(UserName, ' '))) + '.nsf';
// Open the mail database in notes
Maildb := Session.GETDATABASE('', MailDbName);
if not Maildb.ISOPEN then
Maildb.OPENMAIL;
// Set up the new mail document
MailDoc := Maildb.CREATEDOCUMENT;
MailDoc.Form := 'Memo';
MailDoc.sendto := Recipient;
MailDoc.Subject := Subject;
MailDoc.Body := BodyText;
MailDoc.SAVEMESSAGEONSEND := SaveIt;
// Set up the embedded object and attachment and attach it
if Attachment <> '' Then
begin
AttachME := MailDoc.CREATERICHTEXTITEM('Attachment');
EmbedObj := AttachME.EMBEDOBJECT(1454, '', Attachment, 'Attachment');
MailDoc.CREATERICHTEXTITEM('Attachment');
end;
// Send the document
MailDoc.PostedDate := Now; // Gets the mail to appear in the sent items folder
MailDoc.SEND(0, Recipient);
end;
这篇关于Delphi中的电子邮件程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!