用shellexecute发送邮件的问题(50分)

D

deanjoy

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么设置主题啊?
 
在邮件地址前加mailto:
 
我当然知道要加mailto:.但是请注意,我说的是主题!
 
好像是mailto:url?subject=....就可以了
 
好像不是吧,会不会在后面的几个默认nil设置?
 
PanYing 的没错.<br>Emailto的语法如下:<br>EmailTo:someoneEmail?subject=subject of Message&amp;cc=otherEmail<br>其中someoneEmail是接收方的Email,subject of Message是主题,otherEmail是发送方<br>的Email.<br>示范如下:<br>&nbsp; ShellExecute(handle, 'open','mailto:whz98@263.net?subject=主题&amp;cc=fengye2000@263.net', Nil, nil, SW_SHOWNORMAL);
 
那附件呢,内容呢,怎么办。。。还有谁知道吗
 
附件、内容,其实这都跟你用的email软件有关,它支持这些,你就可以用,<br>它不支持,你就不能用。没有一个业界标准的。
 
就比如这句话,发EMAIL就是用OUTLOOK<br>ShellExecute(handle, 'open','mailto:whz98@263.net?subject=主题&amp;cc=fengye2000@263.net', Nil, nil, SW_SHOWNORMAL)
 
<br>作一下补充:<br>&nbsp;Emailto的语法如下:<br>&nbsp;EmailTo:收信人Email地址?subject=主题&amp;cc=发信人Email地址&amp;BCC=附件地址&amp;body=正文内容<br>例如:<br>&nbsp; ShellExecute(handle, 'open','mailto:whz98@263.net?subject=主题&amp;cc=fengye2000@263.net&amp;body=正文&amp;BCC=c:/whz.bmp', Nil, nil, SW_SHOWNORMAL);<br>此示例在Delphi5&amp;OulLook Express5测试通过.<br>该给分了吧!<br><br>&nbsp;
 
&amp;BCC=c:/whz.bmp &nbsp;这个不是附件,是密件抄送。<br><br><br>附件怎么表达,答完后马上给分
 
有没有人回答吗,如果是两个附件呢
 
你的问题是一个接一个啊,而且回答了还不给分,你的第一个问题:怎么设置主题啊?<br>Pan Ying已经算是回答对拉,你的那个添加附件的问题已经是第2个问题拉,这个问题<br>我是知道的,但我觉的在email连接的时候添加附件,没有这个必要拉,你做的软件是拿<br>给别人用,别人发email给你,你还要人家被动发什么附件,是不是别有用心啊,以前我<br>到是做了一个这种东西,可以用来窃去对方资料,但你给的分也太少了点吧,所以这个问<br>题我不想回答你,不过可以告诉你一个也很有用的东西<br>如何通过单击按钮发送DBEdit中的email地址,DBEdit中的email地址可以从数据库中提取<br>var<br>a:string;<br>begin<br>a:=DBEdit1.Text;<br>ShellExecute(Application.Handle,nil,pchar('mailto:'+a+''),nil,nil,SW_SHOWNORMAL);<br>这个在人员资料的编程中很有用哦<br><br>
 
不说没关系,我自己找,我就不信
 
讨论过了,可以用OLE来控制。<br>const olMailItem = 0; <br>var Outlook: OLEVariant; <br>&nbsp; &nbsp; &nbsp;MailItem: Variant; <br>begin <br>&nbsp; try <br>&nbsp; &nbsp; Outlook := GetActiveOleObject('Outlook.Application'); <br>&nbsp; except <br>&nbsp; &nbsp; Outlook := CreateOleObject('Outlook.Application'); <br>&nbsp; end; <br><br>&nbsp; MailItem := Outlook.CreateItem(olMailItem); <br>&nbsp; MailItem.Recipients.Add('Kingron@163.net'); <br>&nbsp; MailItem.Subject := 'your subject'; <br>&nbsp; MailItem.Body := 'Body'; <br>&nbsp; MailItem.Attachments.Add('C:/Windows/system.dat'); <br>&nbsp; MailItem.Send; <br>&nbsp; &nbsp;<br>&nbsp; Oulook := Unassigned; <br>end; <br>
 
这个我知道,其实我就是想按一个按钮,跳出OUTLOOK,然后附件在程序里加进去,就这么简单<br>谁回答了,我马上给分,我的全部分<br>
 
简单,给你一个控件,自己看着办吧。:)<br>unit MapiControl; <br><br>interface <br><br>uses <br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; <br><br>type <br>&nbsp; { Introducing a new Type of Event to get the Errorcode } <br>&nbsp; TMapiErrEvent = procedure(Sender: TObject; ErrCode: Integer) of object; <br><br>&nbsp; TMapiControl = class(TComponent) <br>&nbsp; &nbsp; constructor Create(AOwner: TComponent); override; <br>&nbsp; &nbsp; destructor Destroy; override; <br>&nbsp; private <br>&nbsp; &nbsp; { Private-Deklarationen } <br>&nbsp; &nbsp; FSubject: string; <br>&nbsp; &nbsp; FMailtext: string; <br>&nbsp; &nbsp; FFromName: string; <br>&nbsp; &nbsp; FFromAdress: string; <br>&nbsp; &nbsp; FTOAdr: TStrings; <br>&nbsp; &nbsp; FCCAdr: TStrings; <br>&nbsp; &nbsp; FBCCAdr: TStrings; <br>&nbsp; &nbsp; FAttachedFileName: TStrings; <br>&nbsp; &nbsp; FDisplayFileName: TStrings; <br>&nbsp; &nbsp; FShowDialog: Boolean; <br>&nbsp; &nbsp; FUseAppHandle: Boolean; <br>&nbsp; &nbsp; { Error Events: } <br>&nbsp; &nbsp; FOnUserAbort: TNotifyEvent; <br>&nbsp; &nbsp; FOnMapiError: TMapiErrEvent; <br>&nbsp; &nbsp; FOnSuccess: TNotifyEvent; <br>&nbsp; &nbsp; { +&gt; Changes by Eugene Mayevski [mailto:Mayevski@eldos.org]} <br>&nbsp; &nbsp; procedure SetToAddr(newValue : TStrings); <br>&nbsp; &nbsp; procedure SetCCAddr(newValue : TStrings); <br>&nbsp; &nbsp; procedure SetBCCAddr(newValue : TStrings); <br>&nbsp; &nbsp; procedure SetAttachedFileName(newValue : TStrings); <br>&nbsp; &nbsp; { +&lt; Changes } <br>&nbsp; protected <br>&nbsp; &nbsp; { Protected-Deklarationen } <br>&nbsp; public <br>&nbsp; &nbsp; { Public-Deklarationen } <br>&nbsp; &nbsp; ApplicationHandle: THandle; <br>&nbsp; &nbsp; procedure Sendmail(); <br>&nbsp; &nbsp; procedure Reset(); <br>&nbsp; published <br>&nbsp; &nbsp; { Published-Deklarationen } <br>&nbsp; &nbsp; property Subject: string read FSubject write FSubject; <br>&nbsp; &nbsp; property Body: string read FMailText write FMailText; <br>&nbsp; &nbsp; property FromName: string read FFromName write FFromName; <br>&nbsp; &nbsp; property FromAdress: string read FFromAdress write FFromAdress; <br>&nbsp; &nbsp; property Recipients: TStrings read FTOAdr write SetTOAddr; <br>&nbsp; &nbsp; property CopyTo: TStrings read FCCAdr write SetCCAddr; <br>&nbsp; &nbsp; property BlindCopyTo: TStrings read FBCCAdr write SetBCCAddr; <br>&nbsp; &nbsp; property AttachedFiles: TStrings read FAttachedFileName write SetAttachedFileName; <br>&nbsp; &nbsp; property DisplayFileName: TStrings read FDisplayFileName; <br>&nbsp; &nbsp; property ShowDialog: Boolean read FShowDialog write FShowDialog; <br>&nbsp; &nbsp; property UseAppHandle: Boolean read FUseAppHandle write FUseAppHandle; <br><br>&nbsp; &nbsp; { Events: } <br>&nbsp; &nbsp; property OnUserAbort: TNotifyEvent read FOnUserAbort write FOnUserAbort; <br>&nbsp; &nbsp; property OnMapiError: TMapiErrEvent read FOnMapiError write FOnMapiError; <br>&nbsp; &nbsp; property OnSuccess: TNotifyEvent read FOnSuccess write FOnSuccess; <br>&nbsp; end; <br><br>procedure Register; <br><br>implementation <br><br>uses Mapi; <br><br>{ Register the component: } <br>procedure Register; <br>begin <br>&nbsp; RegisterComponents('expectIT', [TMapiControl]); <br>end; <br><br>{ TMapiControl } <br><br>constructor TMapiControl.Create(AOwner: TComponent); <br>begin <br>&nbsp; inherited Create(AOwner); <br>&nbsp; FOnUserAbort := nil; <br>&nbsp; FOnMapiError := nil; <br>&nbsp; FOnSuccess := nil; <br>&nbsp; FSubject := ''; <br>&nbsp; FMailtext := ''; <br>&nbsp; FFromName := ''; <br>&nbsp; FFromAdress := ''; <br>&nbsp; FTOAdr := TStringList.Create; <br>&nbsp; FCCAdr := TStringList.Create; <br>&nbsp; FBCCAdr := TStringList.Create; <br>&nbsp; FAttachedFileName := TStringList.Create; <br>&nbsp; FDisplayFileName := TStringList.Create; <br>&nbsp; FShowDialog := False; <br>&nbsp; ApplicationHandle := Application.Handle; <br>end; <br><br>{ +&gt; Changes by Eugene Mayevski [mailto:Mayevski@eldos.org]} <br>procedure TMapiControl.SetToAddr(newValue : TStrings); <br>begin <br>&nbsp; FToAdr.Assign(newValue); <br>end; <br><br>procedure TMapiControl.SetCCAddr(newValue : TStrings); <br>begin <br>&nbsp; FCCAdr.Assign(newValue); <br>end; <br><br>procedure TMapiControl.SetBCCAddr(newValue : TStrings); <br>begin <br>&nbsp; FBCCAdr.Assign(newValue); <br>end; <br><br>procedure TMapiControl.SetAttachedFileName(newValue : TStrings); <br>begin <br>&nbsp; FAttachedFileName.Assign(newValue); <br>end; <br>{ +&lt; Changes } <br><br>destructor TMapiControl.Destroy; <br>begin <br>&nbsp; FTOAdr.Free; <br>&nbsp; FCCAdr.Free; <br>&nbsp; FBCCAdr.Free; <br>&nbsp; FAttachedFileName.Free; <br>&nbsp; FDisplayFileName.Free; <br>&nbsp; inherited destroy; <br>end; <br><br>{ Reset the fields for re-use} <br>procedure TMapiControl.Reset; <br>begin <br>&nbsp; FSubject := ''; <br>&nbsp; FMailtext := ''; <br>&nbsp; FFromName := ''; <br>&nbsp; FFromAdress := ''; <br>&nbsp; FTOAdr.Clear; <br>&nbsp; FCCAdr.Clear; <br>&nbsp; FBCCAdr.Clear; <br>&nbsp; FAttachedFileName.Clear; <br>&nbsp; FDisplayFileName.Clear; <br>end; <br><br>{ Send the Mail via the API, this procedure composes and sends <br>&nbsp; the Email } <br>procedure TMapiControl.Sendmail; <br>var <br>&nbsp; MapiMessage: TMapiMessage; <br>&nbsp; MError: Cardinal; <br>&nbsp; Sender: TMapiRecipDesc; <br>&nbsp; PRecip, Recipients: PMapiRecipDesc; <br>&nbsp; PFiles, Attachments: PMapiFileDesc; <br>&nbsp; i: Integer; <br>&nbsp; AppHandle: THandle; <br>begin <br>&nbsp; { First we store the Application Handle, if not <br>&nbsp; &nbsp; the Component might fail to send the Email or <br>&nbsp; &nbsp; your calling Program gets locked up. } <br>&nbsp; AppHandle := Application.Handle; <br><br>&nbsp; { We need all recipients to alloc the memory } <br>&nbsp; MapiMessage.nRecipCount := FTOAdr.Count + FCCAdr.Count + FBCCAdr.Count; <br>&nbsp; GetMem(Recipients, MapiMessage.nRecipCount * sizeof(TMapiRecipDesc)); <br><br>&nbsp; try <br>&nbsp; &nbsp; with MapiMessage do <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; ulReserved := 0; <br>&nbsp; &nbsp; &nbsp; { Setting the Subject: } <br>&nbsp; &nbsp; &nbsp; lpszSubject := PChar(Self.FSubject); <br><br>&nbsp; &nbsp; &nbsp; { ... the Body: } <br>&nbsp; &nbsp; &nbsp; lpszNoteText := PChar(FMailText); <br><br>&nbsp; &nbsp; &nbsp; lpszMessageType := nil; <br>&nbsp; &nbsp; &nbsp; lpszDateReceived := nil; <br>&nbsp; &nbsp; &nbsp; lpszConversationID := nil; <br>&nbsp; &nbsp; &nbsp; flFlags := 0; <br><br>&nbsp; &nbsp; &nbsp; { and the sender: (MAPI_ORIG) } <br>&nbsp; &nbsp; &nbsp; Sender.ulReserved := 0; <br>&nbsp; &nbsp; &nbsp; Sender.ulRecipClass := MAPI_ORIG; <br>&nbsp; &nbsp; &nbsp; Sender.lpszName := PChar(FromName); <br>&nbsp; &nbsp; &nbsp; Sender.lpszAddress := PChar(FromAdress); <br>&nbsp; &nbsp; &nbsp; Sender.ulEIDSize := 0; <br>&nbsp; &nbsp; &nbsp; Sender.lpEntryID := nil; <br>&nbsp; &nbsp; &nbsp; lpOriginator := @Sender; <br><br>&nbsp; &nbsp; &nbsp; PRecip := Recipients; <br><br>&nbsp; &nbsp; &nbsp; { We have multiple recipients: (MAPI_TO) <br>&nbsp; &nbsp; &nbsp; &nbsp; and setting up each: } <br>&nbsp; &nbsp; &nbsp; if nRecipCount &gt; 0 then <br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; for i := 1 to FTOAdr.Count do <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulReserved := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulRecipClass := MAPI_TO; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { lpszName should carry the Name like in the <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contacts or the adress book, I will take the <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; email adress to keep it short: } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpszName := PChar(FTOAdr.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { If you use this component with Outlook97 or 2000 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and not some of Express versions you will have to set <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'SMTP:' in front of each (email-) adress. Otherwise <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Outlook/Mapi will try to handle the Email on itself. <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sounds strange, just erease the 'SMTP:', compile, compose <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a mail and take a look at the resulting email adresses <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (right click). <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpszAddress := PChar('SMTP:' + FTOAdr.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulEIDSize := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpEntryID := nil; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(PRecip); <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br><br>&nbsp; &nbsp; &nbsp; &nbsp; { Same with the carbon copy recipients: (CC, MAPI_CC) } <br>&nbsp; &nbsp; &nbsp; &nbsp; for i := 1 to FCCAdr.Count do <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulReserved := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulRecipClass := MAPI_CC; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpszName := PChar(FCCAdr.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpszAddress := PChar('SMTP:' + FCCAdr.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulEIDSize := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpEntryID := nil; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(PRecip); <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br><br>&nbsp; &nbsp; &nbsp; &nbsp; { ... and the blind copy recipients: (BCC, MAPI_BCC) } <br>&nbsp; &nbsp; &nbsp; &nbsp; for i := 1 to FBCCAdr.Count do <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulReserved := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulRecipClass := MAPI_BCC; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpszName := PChar(FBCCAdr.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpszAddress := PChar('SMTP:' + FBCCAdr.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.ulEIDSize := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRecip^.lpEntryID := nil; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(PRecip); <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; lpRecips := Recipients; <br><br>&nbsp; &nbsp; &nbsp; { Now we process the attachments: } <br><br>&nbsp; &nbsp; &nbsp; if FAttachedFileName.Count &gt; 0 then <br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; nFileCount := FAttachedFileName.Count; <br>&nbsp; &nbsp; &nbsp; &nbsp; GetMem(Attachments, MapiMessage.nFileCount * sizeof(TMapiFileDesc)); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; PFiles := Attachments; <br><br>&nbsp; &nbsp; &nbsp; &nbsp; { Fist setting up the display names (without path): } <br>&nbsp; &nbsp; &nbsp; &nbsp; FDisplayFileName.Clear; <br>&nbsp; &nbsp; &nbsp; &nbsp; for i := 0 to FAttachedFileName.Count - 1 do <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FDisplayFileName.Add(ExtractFileName(FAttachedFileName)); <br><br>&nbsp; &nbsp; &nbsp; &nbsp; if nFileCount &gt; 0 then <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { Now we pass the attached file (their paths) to the <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; structure: } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i := 1 to FAttachedFileName.Count do <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { Setting the complete Path } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attachments^.lpszPathName := PChar(FAttachedFileName.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { ... and the displayname: } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attachments^.lpszFileName := PChar(FDisplayFileName.Strings[i - 1]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attachments^.ulReserved := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attachments^.flFlags := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { Position has to be -1, please see the WinApi Help <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for details. } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attachments^.nPosition := Cardinal(-1); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attachments^.lpFileType := nil; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(Attachments); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; &nbsp; lpFiles := PFiles; <br>&nbsp; &nbsp; &nbsp; end <br>&nbsp; &nbsp; &nbsp; else <br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; nFileCount := 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; lpFiles := nil; <br>&nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; end; <br><br>&nbsp; &nbsp; { Send the Mail, silent or verbose: <br>&nbsp; &nbsp; &nbsp; Verbose means in Express a Mail is composed and shown as setup. <br>&nbsp; &nbsp; &nbsp; In non-Express versions we show the Login-Dialog for a new <br>&nbsp; &nbsp; &nbsp; session and after we have choosen the profile to use, the <br>&nbsp; &nbsp; &nbsp; composed email is shown before sending <br><br>&nbsp; &nbsp; &nbsp; Silent does currently not work for non-Express version. We have <br>&nbsp; &nbsp; &nbsp; no Session, no Login Dialog so the system refuses to compose a <br>&nbsp; &nbsp; &nbsp; new email. In Express Versions the email is sent in the <br>&nbsp; &nbsp; &nbsp; background. <br>&nbsp; &nbsp; &nbsp;} <br>&nbsp; &nbsp; if FShowDialog then <br>&nbsp; &nbsp; &nbsp; MError := MapiSendMail(0, AppHandle, MapiMessage, MAPI_DIALOG or MAPI_LOGON_UI or MAPI_NEW_SESSION, 0) <br>&nbsp; &nbsp; else <br>&nbsp; &nbsp; &nbsp; MError := MapiSendMail(0, AppHandle, MapiMessage, 0, 0); <br><br>&nbsp; &nbsp; { Now we have to process the error messages. There are some <br>&nbsp; &nbsp; &nbsp; defined in the MAPI unit please take a look at the unit to get <br>&nbsp; &nbsp; &nbsp; familiar with it. <br>&nbsp; &nbsp; &nbsp; I decided to handle USER_ABORT and SUCCESS as special and leave <br>&nbsp; &nbsp; &nbsp; the rest to fire the "new" error event defined at the top (as <br>&nbsp; &nbsp; &nbsp; generic error) <br><br>&nbsp; &nbsp; &nbsp; Not treated as special: <br>&nbsp; &nbsp; &nbsp; MAPI_E_AMBIGUOUS_RECIPIENT, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_ATTACHMENT_NOT_FOUND, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_ATTACHMENT_OPEN_FAILURE, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_BAD_RECIPTYPE, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_FAILURE, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_INSUFFICIENT_MEMORY, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_LOGIN_FAILURE, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_TEXT_TOO_LARGE, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_TOO_MANY_FILES, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_TOO_MANY_RECIPIENTS, <br>&nbsp; &nbsp; &nbsp; &nbsp; MAPI_E_UNKNOWN_RECIPIENT: <br>&nbsp; &nbsp; } <br><br>&nbsp; &nbsp; case MError of <br>&nbsp; &nbsp; &nbsp; MAPI_E_USER_ABORT: <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(FOnUserAbort) then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FOnUserAbort(Self); <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; SUCCESS_SUCCESS: <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(FOnSuccess) then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FOnSuccess(Self); <br>&nbsp; &nbsp; &nbsp; &nbsp; end <br>&nbsp; &nbsp; else begin <br>&nbsp; &nbsp; &nbsp; &nbsp; if Assigned(FOnMapiError) then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FOnMapiError(Self, MError); <br>&nbsp; &nbsp; &nbsp; end; <br><br>&nbsp; &nbsp; end; <br>&nbsp; finally <br>&nbsp; &nbsp; { Finally we do the cleanups, the message should be on its way } <br>&nbsp; &nbsp; FreeMem(Recipients, MapiMessage.nRecipCount * sizeof(TMapiRecipDesc)); <br>&nbsp; end; <br>end; <br><br>{ <br>&nbsp; Please treat this as free. If you improve the component <br>&nbsp; I would be glad to get a copy. <br>} <br><br>end. <br>&nbsp;
 
EMAIL 的控件我也有,我就想用ShellExecute 这个函数,因为这个简单。<br><br>
 
嗨,早说啊。目前我看用ShellExecute没有办法了。
 
其他都可以,就是这个附件不行,还真奇怪,前面有人说他有办法的,不过要高分,我可没多少分数了<br><br>哈哈哈哈
 
顶部