INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Assigning a host to idSMTP

Assigning a host to idSMTP

(OP)
Hi I know this piece of programming works and that when I haven't declared my idSMTP.Host it gives me "Protect Guide.exe raised exception class EIdSocketError with message 'Socket Error #10061", so I have gathered a bunch of hosts and made an IF to support each host (it depends on the sender E-Mail which host should be declared but a can't get my IF to work - I still get that Error Message.

Here is some of my code:

> Procedure SednMailClick(Sender : TObject);
> var
> sSender, sSubject, sMessage, sServer, sEMail : String;
> begin
> sSender := edtSender.Text;
> sSubject := edtSubject.Text;
> sMessage := InligtingMemo.Lines.Text;
> sEMail := frmEMail.edtSender.Text;
> sServer := Copy(sEMail,(pos('@', sEMail)), (Pos('.', sEMail)-1));
>
> //setup idSMTP connection parameters
> If sServer = 'gmail'
> Then idSMTP.Host := 'smtp.gmail.com'
> Else If sServer = 'telkomsa'
> Then idSMTP.Host := 'smtp.dsl.telkomsa.net'
> Else If sServer = 'saix'
> Then idSMTP.Host := 'smtp.saix.net'
> Else If sServer = 'mweb'
> Then idSMTP.Host := 'smtp.mweb.co.za'
> Else If sServer = 'vodacom'
> Then idSMTP.Host := 'smtp.vodacom.co.za'
> Else If sServer = 'mtn'
> Then idSMTP.Host := 'mail.mtn.co.za'
> Else If sServer = 'cmobile'
> Then idSMTP.Host := 'mail.cmobile.co.za'
> Else If sServer = 'iburst'
> Then idSMTP.Host := 'smtp.iburst.co.za'
> Else If sServer = 'isdsl'
> Then idSMTP.Host := 'smtp.isdsl.net'
> Else If sServer = 'isgms'
> Then idSMTP.Host := 'smtp.isgms.net'
> Else If sServer = 'dial-up'
> Then idSMTP.Host := 'smtp.dial-up.net'
> Else If sServer = 'neomail'
> Then idSMTP.Host := 'smtp.neomail.co.za'
> Else If sServer = 'absamail'
> Then idSMTP.Host := 'smtp.absamail.co.za'
> Else If sServer = 'absa'
> Then idSMTP.Host := 'mail.absa.co.za'
> Else If sServer = 'lantic'
> Then idSMTP.Host := 'smtp.lantic.net'
> Else If sServer = 'netactive'
> Then idSMTP.Host := 'smtp.netactive.co.za'
> Else If sServer = 'polka'
> Then idSMTP.Host := 'smtp.polka.co.za'
> Else If sServer = 'wa'
> Then idSMTP.Host := 'smtp.wa.co.za';
> idSMTP.Port := 25; //smtp service usually runs on this port
> idSMTP.Password := '';

> //setup idmessage parameters
> idmessage.From.address := sSender;
> idmessage.Recipients.EMailAddresses := ''; //I declared my E-Mail
> since I only want who ever sends the e-mail to send it to me
> idmessage.CCList.EMailAddresses := '';
> idmessage.BccList.EMailAddresses := '';
> idmessage.Subject := sSubject;
> idmessage.Body.Text := sMessage;
>
> //send the message
> try
> try
> idSMTP.Connect;
> idSMTP.send(idmessage);
>
> finally
>
> //disconnect from server
> if IdSMTP.Connected
> then IdSMTP.Disconnect;
> end;
>
> finally
> end;
>
> end;


So I know my fault lies in my If or at my sServer with my Copy/Pos(position) Coding. Please Help!

RE: Assigning a host to idSMTP

Hi,

Try:

CODE -->

var
  p, q: integer;
  // ...
begin
// ...
p := Pos('@', sEmail) + 1;
q := PosEx('.', sEmail, p);
if (p > 1) and
   (q > p) then
  begin
    sServer := Copy(sEMail, p, q - p);
    ShowMessage(sServer); // ***** only for test *****
    if sServer = 'gmail'
        // ...
  end
else
    ShowMessage('Email incorrect'); 

Hope this helps.

http://www.imoveisemexposicao.com.br/imoveis-venda-são_paulo-residencial-apartamento

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close