SMPT Thread Program !

Giganews Newsgroups
Subject: SMPT Thread Program !
Posted by:  Edward. Z. F. M. (edward.z.f…@gmail.com)
Date: Wed, 14 Feb 2007

What i need to do to fix ma my SMPT Thread program ?

What is the max number of therads i can use in SMTP ?

//---------------------------------------------------------------------------
void __fastcall TFormMain::SendMail()
{
      if(idSmtp->Connected()){
              try{
                      try{
                              idSmtp->Send(idMess);
                        }
                      catch(...){
                              ShowMessage("ERROR");
                        }
              }
              __finally{
                      idSmtp->Disconnect();
              }
      }
      else{
              try{
                      try{
                              idSmtp->Connect();
                              idSmtp->Send(idMess);
                      }
                      catch(...){
                              ShowMessage("ERROR");
                      }
              }
              __finally{
                      idSmtp->Disconnect();
              }
      }
}

//---------------------------------------------------------------------------__fastcall TFormMain::SendMailThread(const String& _FromMail,const String&_MailSubject,TStrings * _s,const String& _SendDestMail,const String&_HideSend,const String& _CopySend,const String& _SmtpServer,const String&_User,const String& _Pass,bool CreateSuspended){  idSmtp = new TIdSMTP(0);  idMess = new TIdMessage(0);  idSmtp->Username = _User;  idSmtp->Password = _Pass;  idSmtp->Host = _SmtpServer;  idSmtp->AuthenticationType = atLogin;  idSmtp->Connect();  s_SendDestMail = _DestMail;  idMess->Clear();  idMess->From->Text = _FromMail;  idMess->Recipients->EMailAddresses = _SendDestMail;  idMess->Subject = _MailSubject;  idMess->Body->Assign(_s);  idMess->BccList->EMailAddresses = _CopySend;  idMess->Priority = TIdMessagePriority(2);  idMess->CCList->EMailAddresses = _HideSend;  idMess->From->Address = _FromMail;  s_MailSend = _SendDestMail;  s_MailCopy = _CopySend ;  s_MailHide = _HideSend ;  idSmtp->Send(idMess);  SendMail();  this->FreeOnTerminate = true;}//---------------------------------------------------------------------------void __fastcall TFormMain::ButtonSendThreadClick(TObject *Sender){  for(int i = 0; i < RichEditNewletters->Lines->Count  ; i++)  {    RichEditMsg->Lines->Add(AnsiString(Now()));    EditSubject->Text = AnsiString(Now());    SendMailThread(User, EditSubject->Text,  RichEditMsg->Lines,RichEditNewletters->Lines->Strings[i], "",  "",  SmtpServer,  User,  Senha,false);    Label2->Caption = AnsiString(i);    Application->ProcessMessages();  }}//---------------------------------------------------------------------------void __fastcall TFormMain::FormDestroy(TObject *Sender){  delete idSmtp;  delete idMess;}//---------------------------------------------------------------------------class TFormMain : public TForm{__published: // IDE-managed Components      private: // User declarations      TIdSMTP *idSmtp;      TIdMessage *idMess;      String s_MailSend;      String s_MailCopy;      String s_MailHide;public:  // User declarations        __fastcall TFormMain(TComponent* Owner);        void __fastcall SendMail();        __fastcall SendMailThread(const String& _FromMail,const String&_MailSubject,TStrings * s,const String& _SendDestMail,const String&_HideSend,const String& _CopySend,const String& _SmtpServer,const String&_User,const String& _Pass,bool CreateSuspended);protected:        void __fastcall Execute();};

Replies