Dica: Dá uma lida no código e repare no uso da variável nFileCount. Abraço, Ricardo.
1) Evite escrever suas mensagens usando somente LETRAS MAIÚSCULAS. 2) Revise o texto de sua mensagem. Uma mensagem bem escrita é melhor compreendida. 3) Vamos ajudar o Grupo e o Yahoo! Apague o conteúdo irrelevante! --- Em seg, 28/9/09, Fellipe Henrique <felli...@gmail.com> escreveu: De: Fellipe Henrique <felli...@gmail.com> Assunto: [delphi-br] Como enviar vários anexos usando MAPI via Delphi? Para: delphi-br@yahoogrupos.com.br Data: Segunda-feira, 28 de Setembro de 2009, 13:50 Amigos, achei um codigo na internet que usa MAPI pra enviar email.. porém só aceita 1 anexo... alguém teria algum codigo que aceitaria mais de 1 anexo? Segue o codigo: function SendMailMAPI( const Subject, Body, FileName, SenderName, SenderEMail, RecepientName, RecepientEMail: string): Integer; var message: TMapiMessage; lpSender, lpRecepient: TMapiRecipDesc; FileAttach: TMapiFileDesc; SM: TFNMapiSendMail; MAPIModule: HModule; SL: TStringList; i: integer; begin FillChar(message, SizeOf(message) , 0); with message do begin if (Subject <> '') then begin lpszSubject := PChar(Subject) end; if (Body <> '') then begin lpszNoteText := PChar(Body) end; if (SenderEMail <> '') then begin lpSender.ulRecipCla ss := MAPI_ORIG; if (SenderName = '') then begin lpSender.lpszName := PChar(SenderEMail) end else begin lpSender.lpszName := PChar(SenderName) end; lpSender.lpszAddres s := PChar('SMTP: ' + SenderEMail) ; lpSender.ulReserved := 0; lpSender.ulEIDSize := 0; lpSender.lpEntryID := nil; lpOriginator := @lpSender; end; if (RecepientEMail <> '') then begin lpRecepient. ulRecipClass := MAPI_TO; if (RecepientName = '') then begin lpRecepient. lpszName := PChar(RecepientEMai l) end else begin lpRecepient. lpszName := PChar(RecepientName ) end; lpRecepient. lpszAddress := PChar('SMTP: ' + RecepientEMail) ; lpRecepient. ulReserved := 0; lpRecepient. ulEIDSize := 0; lpRecepient. lpEntryID := nil; nRecipCount := 1; lpRecips := @lpRecepient; end else begin lpRecips := nil end; if (FileName = '') then begin nFileCount := 0; lpFiles := nil; end else begin SL := TStringList. Create; try SL.Text := Filename; for i := 0 to SL.Count - 1 do begin FillChar(FileAttach , SizeOf(FileAttach) , 0); FileAttach.nPositio n := Cardinal($FFFFFFFF) ; FileAttach.lpszPath Name := PChar(SL.Strings[ i]);//PChar( FileName) ; Inc(nFileCount) ;//nFileCount := 1; lpFiles := @FileAttach; end; finally SL.Free; end; end; end; MAPIModule := LoadLibrary( PChar(MAPIDLL) ); if MAPIModule = 0 then begin Result := -1 end else begin try @SM := GetProcAddress( MAPIModule, 'MAPISendMail' ); if @SM <> nil then begin Result := SM(0, Application. Handle, message, MAPI_DIALOG or MAPI_LOGON_UI, 0); end else begin Result := 1 end; finally FreeLibrary( MAPIModule) ; end; end; if Result <> 0 then begin MessageDlg(' Error sending mail (' + IntToStr(Result) + ').', mtError, [mbOk], 0) end; end; -- ____________ _________ _________ ___ T.·.F.·.A.·. Fellipe Henrique ------------ --------- --------- --------- --------- --------- - CAMPANHA POR UMA INTERNET SEGURA Proteja o endereço de seus amigos como estou protegendo o seu. Ao enviar mensagens use SEMPRE o "Cco" (cópia oculta). Assim TODOS os endereços estarão preservados. E, claro, antes de encaminhar um e-mail, delete todas as informações que apareçam no corpo do e-mail e que possam ser usadas por hackers. ############ ######### ######### ######### [As partes desta mensagem que não continham texto foram removidas] ____________________________________________________________________________________ Veja quais são os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.com [As partes desta mensagem que não continham texto foram removidas]