Einzelnen Beitrag anzeigen

DaCoda

Registriert seit: 21. Jul 2006
Ort: Hamburg
145 Beiträge
 
Delphi 12 Athens
 
#6

AW: Mail aus Programm abschicken

  Alt 16. Apr 2023, 09:47
Hallo Willie1,
ich mache das immer mit Indy-SMTP:
Code:
procedure TfrmMain.SendMail;
var
  AttachmentFile: TIdAttachmentFile;
begin
  try
    AntiFreeze.Active := True;
    Screen.Cursor := crHourGlass;
    try
      with IndyMessage do begin
        Clear;
        Organization := CompanyName;
        From.Name := FromName;
        From.Address := FromAdress;
        Recipients.EMailAddresses := ToAdress;
        Subject := Bodytext;
        ContentTransferEncoding := 'BASE64';
        CharSet := 'ISO-8859-1';

        Body.Add(BodyText03 + BodyText02 + FormatDateTime('dd.mm.yyyy', dmMain.tblProduktionsberichteProduktionszeitAnfang.AsDateTime) + ' - ' + comboSchicht.Text + ' - ' + comboLinie.Text);
        Body.Add('Projektnummer: ' + comboProjektnummer.Text + ' - ' + 'Projektname: ' + comboProjektname.Text + Space + BodyText04);
        Body.Add(BodyText05);
        Body.Add(BodyText06);
        Body.Add(BodyText07);

        AttachmentFile := TIdAttachmentFile.Create(MessageParts, AttachmentFileName);
      end;
      IndySMTP.Host := MailServer;
      IndySMTP.Username := MailUser;
      IndySMTP.Password := MailPassword;
      IndySMTP.Connect;
      if IndySMTP.Connected then begin
        IndySMTP.Send(IndyMessage);
        IndySMTP.Disconnect;
      end;
    except
      if IndySMTP.Connected then
        IndySMTP.Disconnect;
      Screen.Cursor := crDefault;
      FreeAndNil(AttachmentFile);
      AntiFreeze.Active := False;
    end;
  finally
    Screen.Cursor := crDefault;
    FreeAndNil(AttachmentFile);
    AntiFreeze.Active := False;
  end;
end;
Vielleicht hilft dir das ja weiter (?)
Miniaturansicht angehängter Grafiken
sendmail.png  
Debuggers don’t remove bugs, they only show them in slow-motion.
  Mit Zitat antworten Zitat