Peguei esta função na net consigo enviar os e-mails normalmente porem não 
consigo envia-los em formato HTML no  M$ Outlook.
Alguém sabe se tem como?
 
//função para abrir Outlook Express e enviar dados para o mesmo
function SendEMail(Handle: THandle; Mail: TStrings): Cardinal;
type
  TAttachAccessArray = array[0..1] of TMapiFileDesc;
  PAttachAccessArray = ^TAttachAccessArray;
var
  MapiMessage: TMapiMessage;
  Receip: TMapiRecipDesc;
  Attachments: PAttachAccessArray;
  AttachCount: Integer;
  i1: integer;
  FileName: string;
  dwRet: Cardinal;
  MAPI_Session: Cardinal;
  WndList: Pointer;
begin
  Result := MAPI_E_USER_ABORT;
  {}
  dwRet := MapiLogon(Handle, PChar(''), PChar(''), MAPI_LOGON_UI or
    MAPI_USE_DEFAULT, 0, @MAPI_Session);
  if (dwRet <> SUCCESS_SUCCESS) then
  begin
    MessageBox(Handle, PChar('Erro tentando mandar E-Mail...'),
      PChar('Error'),
      MB_ICONERROR or MB_OK);
  end
  else
  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;
      MapiMessage.lpszDateReceived := nil;
      MapiMessage.lpszConversationID := nil;
    end;
    AttachCount := 0;
    for i1 := 0 to MaxInt do
    begin
      if Mail.Values['attachment' + IntToStr(i1)] = '' then
        break;
      Inc(AttachCount);
    end;
    if AttachCount > 0 then
    begin
      GetMem(Attachments, (SizeOf(TMapiFileDesc) * AttachCount));
 
      for i1 := 0 to AttachCount - 1 do
      begin
        FileName := Mail.Values['attachment' + IntToStr(i1)];
        {}
        Attachments^[i1].ulReserved := 0;
        Attachments^[i1].flFlags := MAPI_OLE_STATIC;
        Attachments^[i1].nPosition := Cardinal(-1);
        Attachments^[i1].lpszPathName := StrNew(PChar(FileName));
        Attachments^[i1].lpszFileName :=
          StrNew(PChar(ExtractFileName(FileName)));
        Attachments^[i1].lpFileType := nil;
      end;
      MapiMessage.nFileCount := AttachCount;
      MapiMessage.lpFiles := @Attachments^;
      MapiMessage.flFlags := MAPI_LONG_MSGID;
    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']));
 
    WndList := DisableTaskWindows(0);
    try
      Result := MapiSendMail(MAPI_Session, Handle,
        MapiMessage, MAPI_DIALOG, 0);
        ShowMessage(IntToStr(Result));
    finally
      EnableTaskWindows(WndList);
    end;
 
    for i1 := 0 to AttachCount - 1 do
    begin
      StrDispose(Attachments[i1].lpszPathName);
      StrDispose(Attachments[i1].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);
 
    MapiLogOff(MAPI_Session, Handle, 0, 0);
  end;
end;
 
 
Elcio Domingos Ramos <mailto:[EMAIL PROTECTED]> 
DEMAG Cranes & Components Ltda.
Planejamento Industrial 
Fone: (11)2145-7823 - Fax : (11)2145-7910
 


[As partes desta mensagem que não continham texto foram removidas]



-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

Para ver as mensagens antigas, acesse:
 http://br.groups.yahoo.com/group/delphi-br/messages

Para falar com o moderador, envie um e-mail para:
 [EMAIL PROTECTED] ou [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 



Responder a