谁帮我加上注释~!(100分)

  • 主题发起人 主题发起人 gy0050a
  • 开始时间 开始时间
G

gy0050a

Unregistered / Unconfirmed
GUEST, unregistred user!
function SendEmail(Handle: THandle; Mail: TStrings): Cardinal;<br>//调用MAPI发送Email<br>type<br> &nbsp;TAttachAccessArray = array [0..0] of TMapiFileDesc;<br> &nbsp;PAttachAccessArray = ^TAttachAccessArray;<br>var<br> &nbsp;MapiMessage : TMapiMessage;<br> &nbsp;Receip : TMapiRecipDesc;<br> &nbsp;Attachments : PAttachAccessArray;<br> &nbsp;AttachCount : Integer;<br> &nbsp;iCount : Integer;<br> &nbsp;FileName : string;<br>begin<br> &nbsp;FillChar(MapiMessage, SizeOf(MapiMessage), #0);<br> &nbsp;Attachments := nil;<br> &nbsp;FillChar(Receip,SizeOf(Receip), #0);<br> &nbsp;if Mail.Values['to'] &lt;&gt; '' then begin<br> &nbsp; &nbsp;Receip.ulReserved := 0;<br> &nbsp; &nbsp;Receip.ulRecipClass := MAPI_TO;<br> &nbsp; &nbsp;Receip.lpszName := StrNew(PChar(Mail.Values['to']));<br> &nbsp; &nbsp;Receip.lpszAddress := StrNew(PChar('SMTP:' + Mail.Values['to']));<br> &nbsp; &nbsp;Receip.ulEIDSize := 0;<br> &nbsp; &nbsp;MapiMessage.nRecipCount := 1;<br> &nbsp; &nbsp;MapiMessage.lpRecips := @Receip;<br> &nbsp;end;<br><br> &nbsp;AttachCount := 0;<br> &nbsp;for iCount := 0 to MaxInt do begin<br> &nbsp; &nbsp;if Mail.Values['attachment' + IntToStr(iCount)] = '' then Break;<br> &nbsp; &nbsp;AttachCount := AttachCount + 1;<br> &nbsp;end;<br><br> &nbsp;if AttachCount &gt; 0 then begin<br> &nbsp; &nbsp;GetMem(Attachments,SizeOf(TMapiFileDesc) * AttachCount);<br> &nbsp; &nbsp;for iCount := 0 to (AttachCount - 1) do begin<br> &nbsp; &nbsp; &nbsp;FileName := Mail.Values['attachment' + IntToStr(iCount)];<br> &nbsp; &nbsp; &nbsp;Attachments[iCount].ulReserved := 0;<br> &nbsp; &nbsp; &nbsp;Attachments[iCount].flFlags := 0;<br> &nbsp; &nbsp; &nbsp;Attachments[iCount].nPosition := ULONG($FFFFFFFF);<br> &nbsp; &nbsp; &nbsp;Attachments[iCount].lpszPathName := StrNew(PChar(FileName));<br> &nbsp; &nbsp; &nbsp;Attachments[iCount].lpszFileName := StrNew(PChar(ExtractFileName(FileName)));<br> &nbsp; &nbsp; &nbsp;Attachments[iCount].lpFileType := nil;<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;MapiMessage.nFileCount := AttachCount;<br> &nbsp; &nbsp;MapiMessage.lpFiles := @Attachments^;<br> &nbsp;end;<br><br> &nbsp;if Mail.Values['subject'] &lt;&gt; '' then<br> &nbsp; &nbsp;MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject']));<br> &nbsp;if Mail.Values['body'] &lt;&gt; '' then<br> &nbsp; &nbsp;MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values['body']));<br><br> &nbsp;Result := MapiSendMail(0, Handle, MapiMessage, MAPI_DIALOG*Ord(Handle &lt;&gt; 0) OR MAPI_LOGON_UI OR MAPI_NEW_SESSION, 0);<br><br> &nbsp;for iCount := 0 to (AttachCount - 1) do begin<br> &nbsp; &nbsp;strDispose(Attachments[iCount].lpszPathName);<br> &nbsp; &nbsp;strDispose(Attachments[iCount].lpszFileName);<br> &nbsp;end;<br><br> &nbsp;if assigned(MapiMessage.lpszSubject) then<br> &nbsp; &nbsp;strDispose(MapiMessage.lpszSubject);<br> &nbsp;if assigned(MapiMessage.lpszNoteText) then<br> &nbsp; &nbsp;strDispose(MapiMessage.lpszNoteText);<br> &nbsp;if assigned(Receip.lpszAddress) then<br> &nbsp; &nbsp;strDispose(Receip.lpszAddress);<br> &nbsp;if assigned(Receip.lpszName) then<br> &nbsp; &nbsp;strDispose(Receip.lpszName);<br>end;<br><br>procedure TFrmPrintReport.FlatButton3Click(Sender: TObject);<br>var<br> &nbsp;mail : TStringList;<br>begin<br> &nbsp;mail := TStringList.Create;<br> &nbsp;try<br> &nbsp; &nbsp;//以下邮箱<br> &nbsp; &nbsp;mail.Values['to'] := EmailAdderss;<br> &nbsp; &nbsp;//以下主题<br> &nbsp; &nbsp;mail.Values['subject'] := '主题...';<br> &nbsp; &nbsp;//以下内容<br> &nbsp; &nbsp; mail.Values['body'] := '内容.....';<br> &nbsp; &nbsp;//以下附件<br> &nbsp; &nbsp;mail.Values['attachment0'] :='c:/test.txt' ;<br><br> &nbsp; &nbsp;SendEmail(Application.Handle, mail);<br> &nbsp;finally<br> &nbsp; &nbsp;mail.Free;<br> &nbsp;end;<br><br><br>end;
 
自己顶了!
 
呵呵,太长了
 
大哥们呢,帮帮我吧~!![:(]
 
呵呵,能用就行了。
 
呵呵 大虾请专家吧
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
546
import
I
I
回复
0
查看
1K
import
I
I
回复
0
查看
681
import
I
后退
顶部