Fórum Anexar arquivo no Outlook #255200
20/10/2004
0
Estou desenvolvendo um projeto no Delphi5 que envia mensagens através do Outlook, só que não estou conseguindo anexar um arquivo nesta mensagem.
Alguém sabe que parâmetro devo usar para que, quando a tela de envio do Outlook for aberta o arquivo já estaja em anexo?
Desde já agradeço
Mariana
Mariana
Curtir tópico
+ 0Posts
02/11/2004
Zotti
function EnviarEMail(const De, Para, Assunto, Texto, Arquivo: string; Confirma: Boolean): Integer; var Msg: TMapiMessage; lpSender, lpRecepient: TMapiRecipDesc; FileAttach: TMapiFileDesc; SM: TFNMapiSendMail; MAPIModule: HModule; Flags: Cardinal; begin // cria propriedades da mensagem FillChar(Msg, SizeOf(Msg), 0); with Msg do begin if (Assunto <> ´´) then lpszSubject := PChar(Assunto); if (Texto <> ´´) then lpszNoteText := PChar(Texto); // remetente if (De <> ´´) then begin lpSender.ulRecipClass := MAPI_ORIG; lpSender.lpszName := PChar(De); lpSender.lpszAddress := PChar(De); lpSender.ulReserved := 0; lpSender.ulEIDSize := 0; lpSender.lpEntryID := nil; lpOriginator := @lpSender; end; // destinatário if (Para <> ´´) then begin lpRecepient.ulRecipClass := MAPI_TO; lpRecepient.lpszName := PChar(Para); lpRecepient.lpszAddress := PChar(Para); lpRecepient.ulReserved := 0; lpRecepient.ulEIDSize := 0; lpRecepient.lpEntryID := nil; nRecipCount := 1; lpRecips := @lpRecepient; end else lpRecips := nil; // arquivo anexo if (Arquivo = ´´) then begin nFileCount := 0; lpFiles := nil; end else begin FillChar(FileAttach, SizeOf(FileAttach), 0); FileAttach.nPosition := Cardinal($FFFFFFFF); FileAttach.lpszPathName := PChar(Arquivo); nFileCount := 1; lpFiles := @FileAttach; end; end; // carrega dll e o método para envio do email MAPIModule := LoadLibrary(PChar(MAPIDLL)); if MAPIModule = 0 then Result := -1 else try if Confirma then Flags := MAPI_DIALOG or MAPI_LOGON_UI else Flags := 0; @SM := GetProcAddress(MAPIModule, ´MAPISendMail´); if @SM <> nil then Result := SM(0, Application.Handle, Msg, Flags, 0) else Result := 1; finally FreeLibrary(MAPIModule); end; end;
Agora chama a função como o caso abaixo, dai somente alterar os campos de, para, assunto e ter a opção de escrever o diretorio do arquivo no Edit1.Text ou informar via codigo, vc pode usar um
OpenDialog e usar suas propriedades para buscar o diretorio desse arquivo, agora é só tentar, a função acima é só usar, não precisa alterar nada.
procedure Tform1.SpeedButton8Click(Sender: TObject); var email : string; begin email := Edit1.Text; assuncont:= DmGlobal.TblblNRBL.asstring; EnviarEMail(´de@email´,´para@email´, ´Assunto´, Edit1.Text, True); end
Gostei + 0
02/11/2004
Zotti
Até mais...
Gostei + 0
12/01/2006
Protocolxp
Zotti??? Vc teria um código usando o Mapi do VB para enviar anexos pelo outlook??? as tb não sei se este código abre a janela do outlook?? O que precisaria fazer é apertar um botão em meu projeto do VB e abrir a janela do outlook com o e-mail de envio, e o anexo, tem como fazer isso??? se tiver uma solução me ajude, por favor, obrigado...
Gostei + 0
12/01/2006
Massuda
Gostei + 0
13/01/2006
Protocolxp
Gostei + 0
13/01/2006
Massuda
Gostei + 0
13/01/2006
Protocolxp
Me desculpe mas uma vezx então, estou confundindo tudo aqui neste forum, não costumo usar foruns com frequencia...vou perguntar de novo para o zotti desta vez...
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)