VB的代码:通过API函数ShellExecute再加上一些参数就可以实现发送带附件的邮件,下面是范例: 
Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias _ 
"ShellExecuteA" (ByVal hwnd As Long, _ 
ByVal lpOperation As String, _ 
ByVal lpFile As String, _ 
ByVal lpParameters As String, _ 
ByVal lpDirectory As String, _ 
ByVal nShowCmd As Long) As Long 
Private Const SW_SHOW = 5 Private Sub Command1_Click() 
Debug.Print "[email protected]?subject=MySubject&Attach=""""c:\doc1.doc""""" 
Call ShellExecute(Me.hwnd, "open", _ 
"[email protected]?subject=MySubject&Attach=""c:\doc1.doc""", _ 
vbNullString, vbNullString, SW_SHOW) 
End Sub 
上面的程序将 c:\doc1.doc 作为附件发送出去,上面的代码在OutLook 2000以及 Outlook Exress 5.5下运行通过自己改一下,很简单的。

解决方案 »

  1.   

    Attach=""c:\doc1.doc""好象没有用,附件没有加上去
      

  2.   

    TechnoFantasy(www.applevb.com)的方法不可行,使用mailto是无法发送附件的
      

  3.   

    mailto的用法
    mailto:<address_of_the_receiver>?cc=<whom_a_copy> &bcc=<whom_a_hidden_copy>&subject=<subject_of_the_message> &body=<text_of_the_message>你看看
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q197782
    好像不那么简单
      

  4.   

    http://www.ccw.com.cn/htm/app/aprog/01_2_16_5.asp这个好像也行
      

  5.   

    uses comobj,mapi;procedure TForm1.Button12Click(Sender: TObject);
    var attachs:tstringlist;
    begin
        attachs:= TStringList.Create;
        attachs.add('C:\aaa.txt');
        attachs.add('C:\bbb.txt');
        attachs.add('C:\ccc.txt'); //三个附件
        try
           SendByEmail('收件人','标题','内容',attachs);
           //SendByEmail(Recipients,subjexts,body,attachs);
        finally
        attachs.free;
        end;   
    end;function  SendByEmail(recip,subjects,bodys:string;attachs:TStringList):boolean;
    var mail: TStringList;
        str,str1:string;
        j:integer;
    begin
      result:=false;
      str:=''; str1:='';
      mail := TStringList.Create;
      mail.values['to']      := recip;
      mail.values['subject'] := subjects;
      mail.values['body']    := bodys;
      try
        for j:=0 to attachs.Count-1 do
        begin
          str:=attachs.Strings[j];
          str1:='attachment'+inttostr(j);
          mail.values[str1] := str;
        end;
       SendEMail(Application.Handle, mail);
       finally
       mail.Free;
        end;
       result:=true;
    end;
    FUNCTION SendEMail(Handle : THandle; Mail : TStrings):Cardinal;
    TYPE
      TAttachAccessArray = ARRAY [0..0] OF TMapiFileDesc;
      PAttachAccessArray = ^TAttachAccessArray;
    VAR
      MapiMessage : TMapiMessage;
      Receip      : TMapiRecipDesc;
      Attachments : PAttachAccessArray;
      AttachCount : INTEGER;
      iCount      : INTEGER; 
      FileName    : STRING;
    BEGIN 
      fillChar(MapiMessage, SizeOf(MapiMessage), #0); 
      Attachments := NIL; 
      fillChar(Receip,SizeOf(Receip), #0);
      IF Mail.Values['to'] <> '' 
      THEN 
      BEGIN 
        Receip.ulReserved := 0;
        Receip.ulRecipClass := MAPI_TO; 
        Receip.lpszName := StrNew(PChar(Mail.Values['to']));
        Receip.lpszAddress := StrNew(PChar('SMTP:' + Mail.Values['to'])); 
        Receip.ulEIDSize := 0;
        MapiMessage.nRecipCount := 1; 
        MapiMessage.lpRecips := @Receip; 
      END; 
      AttachCount := 0;
      FOR iCount := 0 TO MaxInt 
      DO 
      BEGIN
        IF Mail.Values['attachment' + IntToStr(iCount)] = '' 
        THEN 
          BREAK;
        AttachCount := AttachCount + 1;
      END; 
      IF AttachCount > 0 
      THEN
      BEGIN 
        GetMem(Attachments,SizeOf(TMapiFileDesc) * AttachCount);
        FOR iCount := 0 TO (AttachCount - 1) 
        DO
        BEGIN 
          FileName := Mail.Values['attachment' + IntToStr(iCount)]; 
          Attachments[iCount].ulReserved := 0; 
          Attachments[iCount].flFlags := 0;
          Attachments[iCount].nPosition := ULONG($FFFFFFFF); 
          Attachments[iCount].lpszPathName := StrNew(PChar(FileName)); 
          Attachments[iCount].lpszFileName := StrNew(PChar(ExtractFileName(FileName))); 
          Attachments[iCount].lpFileType := NIL;
        END; 
        MapiMessage.nFileCount := AttachCount;
        MapiMessage.lpFiles := @Attachments^; 
      END;  IF Mail.Values['subject'] <> '' 
      THEN
        MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject']));
      IF Mail.Values['body'] <> '' 
      THEN 
        MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values['body']));   Result := MapiSendMail(0, Handle, MapiMessage,MAPI_DIALOG*Ord(Handle <> 0) OR MAPI_LOGON_UI OR MAPI_NEW_SESSION, 0);   FOR iCount := 0 TO (AttachCount - 1) 
      DO
      BEGIN
        strDispose(Attachments[iCount].lpszPathName); 
        strDispose(Attachments[iCount].lpszFileName);
      END;  IF assigned(MapiMessage.lpszSubject) 
      THEN 
        strDispose(MapiMessage.lpszSubject);
      IF assigned(MapiMessage.lpszNoteText) 
      THEN 
        strDispose(MapiMessage.lpszNoteText); 
      IF assigned(Receip.lpszAddress)
      THEN
        strDispose(Receip.lpszAddress); 
      IF assigned(Receip.lpszName) 
      THEN
        strDispose(Receip.lpszName); 
    END;