Einzelnen Beitrag anzeigen

SvenLittkowski

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

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

  Alt 5. Feb 2011, 21:25
Things I do wrong. I added code excerpts from your linked sample code, but on Execution (yes, it compiled error-free!) I get the following execution-aborting error message:

Zitat von My Delphi 7:
Project MyProgram.exe raised exception class EIdOSSLOCouldNotLoadSSLLibrary with message 'Could not load SSL library.'. Process stopped. Use Step or Run to continue.
And here the complete code:

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.
  Mit Zitat antworten Zitat