Einzelnen Beitrag anzeigen

SvenLittkowski

Registriert seit: 18. Dez 2004
98 Beiträge
 
#34

AW: Delphi: E-Mail-Versand / E-Mail-Formatierung

  Alt 6. Feb 2011, 03:37
Yes! You was right, and using the new DLLs does not cause the program to error for missing DLLs! But - my program is back to the previous state of halting after having clicked the SEND button. Means, the source code is still faulty. And I can't find the problem with "Run to Cursor" and "Step Over". Es ist zum Mäusemelken!

Hier der Quelltext:

Code:
implementation

uses Box1;

{$R *.dfm}

procedure TEpsilon.FormCreate(Sender: TObject);
begin
 Epsilon.Color:=Alpha.ColorDialog.Color;
end;

procedure TEpsilon.ButtonMailClick(Sender: TObject);
begin
 idSMTP.Host:='smtp.googlemail.com';
 idSMTP.Port:=465; //smtp service usually runs on this port 25
 idSMTP.Password:='MyPassword';
 idSMTP.UseTLS:=utUseExplicitTLS;
 //setup idmessage parameters
 idmessage.From.address:=EditEMail.Text;
 idmessage.Recipients.EMailAddresses:='MyEMail@gmail.com';
 idmessage.CCList.EMailAddresses:='';
 idmessage.BccList.EMailAddresses:='';
 idmessage.Subject:='My E-Mail';
 idmessage.Body.Text:=EditMailEra.Text+EditMailOld.Text+EditmailAmount.Text+EditMailModern.Text;
 idmessage.Body.Text:=idmessage.Body.Text+MemoMail.Lines.Text;
 //check if receipt confirmation is required
// if checkbox1.checked then idmessage.ReceiptRecipient.Text:=edfrom.Text; //if required, set the sendback email address to your email address
 //send the message
 try
  try
   idSMTP.Connect;
   LabelStatus.Caption:='Connecting...'; //…then show the message
   LabelStatus.Hint:='Connecting...'; //…then show the message
   idSMTP.send(idmessage);
   LabelStatus.Caption:='Sending...'; //…then show the message
   LabelStatus.Hint:='Sending...'; //…then show the message
  //if an exception occurs…
  except
   on E: EIdSMTPReplyError do
   begin
    LabelStatus.Caption:=E.Message; //…then show the message
    LabelStatus.Hint:=E.Message; //…then show the message
   end;
  end;
 finally
  //disconnect from server
  if IdSMTP.Connected then
  begin
   IdSMTP.Disconnect;
   LabelStatus.Caption:='Disconnecting...'; //…then show the message
   LabelStatus.Hint:='Disconnecting...'; //…then show the message
  end;
 end;
end;

procedure TEpsilon.ButtonBrowseClick(Sender: TObject); // doesn't function, so I disabled it - for now
begin
// if OpenDialog.Execute then TIdAttachmentFile.Create(idmessage.MessageParts,OpenDialog.FileName);
// AddAttachments;
end;
(*
procedure TEpsilon.AddAttachments; // caused problems, too
var
 li: TListItem;
 idx: Integer;
begin
 //clear the attachment listview
 lvAttachments.Items.Clear;
 //loop through Idmessage and count parts
 for idx:=0 to Pred(Idmessage.MessageParts.Count) do
 begin
  li:=lvAttachments.Items.Add;
  // Check if Idmessage contains any attachments…
  if Idmessage.MessageParts.Items[idx] is TIdAttachmentFile then
  begin
   //if so, get the file names…
   li.Caption:=TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).Filename;
   //and add them to the listview
   li.SubItems.Add(TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).ContentType);
  end
  else
  begin
   li.Caption:=Idmessage.MessageParts.Items[idx].ContentType;
  end;
 end;
end;
*)
procedure TEpsilon.IdSSLIOHandlerSocketOpenSSLStatusInfo(Msg: String);
begin
 LabelStatus.Caption:=Msg;
end;

procedure TEpsilon.IdSMTPStatus(ASender: TObject; const AStatus: TIdStatus;
  const AStatusText: String);
begin
 LabelStatus.Caption:=AStatusText;
end;

end.

Geändert von SvenLittkowski ( 6. Feb 2011 um 04:05 Uhr)
  Mit Zitat antworten Zitat