Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my asp.net application I want to send mail.

it was working currently in one server (domain), but it is not working change the (domain) server why this problem?
Is smtp different for different server or domain?

My code is
C#
DataSet ds = new DataSet();
            MailMessage mail1 = new MailMessage();
            mail1.From = txtemail.Text;
            ds.ReadXml(Server.MapPath("~/Admin/xml/feedbackmail.xml"));
            mail1.To = ds.Tables[0].Rows[0][0].ToString();

            mail1.Body = "Sender : " + txtemail.Text + "\n" + "Name : " + txtname.Text + "\n" + "Phone : " + txtPhone.Text + "\n" + "\n" + "Sub:" + txtsubject.Text + "\n" + "Body :" + txtmsg.Text;
            SmtpMail.SmtpServer.Insert(0, "83.245.63.194");
            SmtpMail.Send(mail1);


My question is, is SmtpMail.SmtpServer.Insert(0, "83.245.63.194") different for different server or site or domain.


My error is The "SendUsing" configuration value is invalid.
Posted
Updated 24-Oct-11 21:40pm
v6
Comments
Dalek Dave 25-Oct-11 3:41am    
Edited for Spelling and Readability.

Check your SMTP IP-Address is accessible from your new Domain/Server.

Run "ping 83.245.63.194" command from command-prompt of your new Server.
 
Share this answer
 
C#
System.Net.Mail.MailMessage obj = new System.Net.Mail.MailMessage();
       
 
     SmtpClient serverobj = new SmtpClient();
            serverobj.Credentials = new NetworkCredential("anilmeets4u@gmail.com", "yourpassword");
            serverobj.Port = 587;
            serverobj.Host = "smtp.gmail.com";
            serverobj.EnableSsl = false;
            obj = new System.Net.Mail.MailMessage();
            obj.From = new MailAddress("YourEmailId", "Google.com", System.Text.Encoding.UTF8);
            obj.To.Add(ASPxtxtToUser.Text);
            obj.CC.Add(ASPxTexttoCc.Text);
            obj.Priority = System.Net.Mail.MailPriority.High;
            obj.Subject = txtSubject.Text;
            string date = DateTime.Now.ToString();
            obj.Body = ASPxMemo1.Text;
            serverobj.Send(obj);
            lblsend.Text = "Your Message Send Sucessfully";


Its Works


Regards,

Anilkumar.D
 
Share this answer
 
v2
Comments
$ultaNn 30-Mar-13 3:28am    
i am getting this error The specified string is not in the form required for an e-mail address.
near SmtpClient serverobj = new SmtpClient();
 
Share this answer
 
take a look
Send Mail
 
Share this answer
 
The chances are that you need to set the authorisation credentials for the new domain.

There is a generic routine which may help you here: Sending an Email in C# with or without attachments: generic routine.[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900