🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #978

Re: Assertion Error while sending email

#978
From: JLoz
Date: Tue, 31 Jul 2007 18:38
88 lines
3974 bytes
I was wrong.  It is still giving me the assertion error.  the code is below.

Think of "Header" as an INI file

void __fastcall TEmail::SendEmail2(TIniTable& Header) {
  int Count;
  dstring j,err;

  IdSMTP1->Host = Header["Host"];
  IdSMTP1->Port = Header["Port"].as_int();

  if( Header["Encripted"].as_int() ){
    IdSMTP1->IOHandler = IdSSLIOHandlerSocketOpenSSL1;
    IdSSLIOHandlerSocketOpenSSL1->PassThrough = true;
    IdSMTP1->UseTLS = utUseExplicitTLS;
    if( Header["EncriptionMethod"] == "TLSv1" ) {
      IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method = sslvTLSv1;
    } else if( Header["EncriptionMethod"] == "SSLv2" ) {
      IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method = sslvSSLv2;
    } else if( Header["EncriptionMethod"] == "SSLv23" ) {
      IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method = sslvSSLv23;
    } else if( Header["EncriptionMethod"] == "SSLv3" ) {
      IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method = sslvSSLv3;
    }
  } else {
    IdSMTP1->UseTLS = utNoTLSSupport;
    IdSMTP1->IOHandler = NULL;
  }
  if( Header["Authenticate"].as_int() ) {
    IdSMTP1->AuthType = Idsmtp::atSASL;
    IdUserPassProvider1->Username = Header["UserName"];
    IdUserPassProvider1->Password = Header["Password"];
    IdSMTP1->Username =  Header["UserName"];
    IdSMTP1->Password = Header["Password"];
  } else {
    IdSMTP1->AuthType = Idsmtp::atNone;
  }

  IdMessage1->Clear();
  IdMessage1->From->Address = Header["From"];
  IdMessage1->Recipients->EMailAddresses = AnsiString(Header["To"]);
  IdMessage1->Subject = Header["Subject"];

  Header.SetSection("$");
  if( Header["Attachments"].as_int() ) {
    Header.SetSection("Body");
    Count = Header["NoOfLines"].as_int();

    TIdText *pText = new TIdText(IdMessage1->MessageParts, NULL);
    pText->ContentType = "text/plain";

    for(int i = 1; i <= Count; ++i) {
      pText->Body->Add(Header[dstring(i)]);
    }
    Header.SetSection("AttachmentList");
    Count = Header["NoOfFiles"].as_int();
    for(int i = 1; i <= Count; ++i) {
      new TIdAttachmentFile(IdMessage1->MessageParts,Header[dstring(i)]);
    }
    IdMessage1->ContentType = "multipart/mixed";
  } else {
    Header.SetSection("Body");
    Count = Header["NoOfLines"].as_int();
    for(int i = 1; i <= Count; ++i) {
     IdMessage1->Body->Add(Header[dstring(i)]);
    }
    IdMessage1->ContentType = "text/plain";
  }

  Header.SetSection("$");
  try {
    IdSMTP1->Connect();
    try {
      IdSMTP1->Send(IdMessage1);
    } __finally {
      IdSMTP1->Disconnect(true);
    }
    Header.Set("Result", "1");
  } catch (const Exception& E) {
    if (!UpperCase(E.Message).Pos("RANGE CHECK ERROR")) {
      err = E.Message;
      Header.Set("Error", E.Message);
      Header.Set("Result", "0");
    }
  }
  IdMessage1->Clear();
  if(err != "") throw Exception(AnsiString(err));
} 
Technical Details
Message-ID: <46af818e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46ae4529$1@newsgroups.borland.com> <46af7382@newsgroups.borland.com> <3mtua39vadcc2de0p2ertm0fl224sevvu7@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,da4e10289ba23828
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "JLoz" <jfsierra@excite.com>
From: "JLoz" <jfsierra@excite.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <46ae4529$1@newsgroups.borland.com> <46af7382@newsgroups.borland.com> <3mtua39vadcc2de0p2ertm0fl224sevvu7@4ax.com>
Subject: Re: Assertion Error while sending email
Date: Tue, 31 Jul 2007 14:38:08 -0400
Lines: 90
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 63.163.143.187
Message-ID: <46af818e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1185907086 63.163.143.187 (31 Jul 2007 11:38:06 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail