SMTPRelay & .NET

Giganews Newsgroups
Subject: SMTPRelay & .NET
Posted by:  Guldil (guldilwanadoofr)
Date: Wed, 6 Dec 2006

Hy,

I tried to use the SMTPRelay with .NET 1.1 & C#. I used the SMTPRelay Sample found on the Indy Project Site (In Delphi, i just try to convert it...)

Here the code i put on the Send Button :

Indy.Sockets.SMTPRelay oSmtpRelay = new Indy.Sockets.SMTPRelay();
            oSmtpRelay.OnDirectSMTPStatus +=new Indy.Sockets.TIdSMTPRelayStatus(oSmtpRelay_OnDirectSMTPStatus);
            oSmtpRelay.DNSServer = myDNSIP;

            Indy.Sockets.Message oMsg = new Indy.Sockets.Message();
            
            oMsg.From.Text = txtSender.Text;
            oMsg.Sender.Text = txtSender.Text;
            oMsg.Recipients.EMailAddresses = txtRecipients.Text;
            oMsg.Subject = txtSubject.Text;
            oMsg.Body.Text = txtBody.Text;

            oSmtpRelay.Connect();
            if (oSmtpRelay.Connected())
            {
                oSmtpRelay.Send(oMsg);
                oSmtpRelay.Disconnect();
            }
            else{
                Msg("Unable to connect...");
            }

When i execute this, i get an error:
EIDHostRequired on the oSmtpRelay.Connected() method...
I tried differents DNS server, always the same error.

Any idea ?

Thanks

Guldil

Replies