sendmail.pas
来自「Use the crypto module to encrypt sensiti」· PAS 代码 · 共 58 行
PAS
58 行
unit SendMail;
interface
uses
sx_Mapi, Classes, SysUtils, Windows;
function smSendMail(smRecipients : TStrings; smSubject : String;
smBody : String; smFileName : String) : Boolean;
procedure smInitialise(Session : TsxMAPI_Session);
implementation
uses dmHPFUnit;
function smSendMail(smRecipients : TStrings; smSubject : String;
smBody : String; smFileName : String) : Boolean;
var
msg : TsxMAPI_Message;
f : TsxMAPI_Folder;
MemStr : TMemoryStream;
begin
MemStr := TMemoryStream.Create;
Try
if FileExists(smFileName) then
begin
MemStr.LoadFromFile(smFileName);
end;
f := dmHPF.sxSession.Folder[sxftOutbox];
msg := f.CreateMessage;
msg.SetRecepientsList(sxrtTo, smRecipients);
msg.Subject := smSubject;
msg.Body := smBody;
if smFileName <> ''
then begin
msg.AddAttachment;
msg.Attachment[0].Name := 'Your Attachment';
msg.Attachment[0].FileName := smFileName;
msg.Attachment[0].Write(MemStr);
end;
msg.Save;
msg.Send;
finally
Result := True;
MemStr.Free;
end;
end;
procedure smInitialise(Session : TsxMAPI_Session);
begin
//Initialise the Session with a TsxMAPI_Session component on the Datamodule
Session.Logon;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?