MelodyRogueAngel
Programmer
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!
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!