473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Error sending mail in .net

when i m sending mail i received error from symantec Antivirus" Your email message was unable to be sent because your mail server rejected the message
550-5.7.1[122.163.196.231] the ip you’re using to send mail is not authorized"

i have configure smtp server put 127.0.0.1 ip in relay and also put 127.0.0.1 ip in connection.
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Web;
  8. using System.Web.Mail;
  9. using System.Web.SessionState;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. using System.Web.UI.HtmlControls;
  13.  
  14. namespace EMailSample
  15. {
  16.     public partial class SendMail : System.Web.UI.Page
  17.     {
  18.  
  19.         protected void Page_Load(object sender, System.EventArgs e)
  20.         {
  21.             if (!IsPostBack)
  22.             {
  23.             }
  24.             lblMessage.Text = "";
  25.         }
  26.  
  27.         #region Web Form Designer generated code
  28.         override protected void OnInit(EventArgs e)
  29.         {
  30.             //
  31.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  32.             //
  33.             InitializeComponent();
  34.             base.OnInit(e);
  35.         }
  36.  
  37.         /// <summary>
  38.         /// Required method for Designer support - do not modify
  39.         /// the contents of this method with the code editor.
  40.         /// </summary>
  41.         private void InitializeComponent()
  42.         {
  43.  
  44.         }
  45.         #endregion
  46.  
  47.         protected void btnsend_Click(object sender, EventArgs e)
  48.         {
  49.             try
  50.             {
  51.                 /* Create a new blank MailMessage */
  52.                 MailMessage mailMessage = new MailMessage();
  53.  
  54.                 mailMessage.From = txtSender.Text;
  55.                 mailMessage.To = txtReceiver.Text;
  56.                 mailMessage.Cc = txtCc.Text;
  57.                 mailMessage.Bcc = txtBcc.Text;
  58.                 mailMessage.Subject = txtSubject.Text;
  59.                 mailMessage.Body = txtBody.Text;
  60.  
  61.                 /* Set the properties of the MailMessage to the
  62.                    values on the form  */
  63.                 if (rblMailFormat.SelectedItem.Text == "Text")
  64.                     mailMessage.BodyFormat = MailFormat.Text;
  65.                 else
  66.                     mailMessage.BodyFormat = MailFormat.Html;
  67.  
  68.                 /* We use the following variables to keep track of
  69.                    attachments and after we can delete them */
  70.                 string attach1 = null;
  71.                 string attach2 = null;
  72.                 string attach3 = null;
  73.  
  74.                 /*strFileName has a attachment file name for 
  75.                   attachment process. */
  76.                 string strFileName = null;
  77.  
  78.                 /* Bigining of Attachment1 process   & 
  79.                    Check the first open file dialog for a attachment */
  80.                 if (inpAttachment1.PostedFile != null)
  81.                 {
  82.                     /* Get a reference to PostedFile object */
  83.                     HttpPostedFile attFile = inpAttachment1.PostedFile;
  84.                     /* Get size of the file */
  85.                     int attachFileLength = attFile.ContentLength;
  86.                     /* Make sure the size of the file is > 0  */
  87.                     if (attachFileLength > 0)
  88.                     {
  89.                         /* Get the file name */
  90.                         strFileName = Path.GetFileName(inpAttachment1.PostedFile.FileName);
  91.                         /* Save the file on the server */
  92.  
  93.                         string path = Server.MapPath(strFileName);
  94.                         inpAttachment1.PostedFile.SaveAs(path);
  95.                         /* Create the email attachment with the uploaded file */
  96.                         MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
  97.                         /* Attach the newly created email attachment */
  98.                         mailMessage.Attachments.Add(attach);
  99.                         /* Store the attach filename so we can delete it later */
  100.                         attach1 = strFileName;
  101.                     }
  102.                 }
  103.                 /* Attachment-2 Repeat previous step */
  104.                 if (inpAttachment2.PostedFile != null)
  105.                 {
  106.                     HttpPostedFile attFile = inpAttachment2.PostedFile;
  107.                     int attachFileLength = attFile.ContentLength;
  108.                     if (attachFileLength > 0)
  109.                     {
  110.                         strFileName = Path.GetFileName(inpAttachment2.PostedFile.FileName);
  111.                         inpAttachment2.PostedFile.SaveAs(Server.MapPath(strFileName));
  112.                         MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
  113.                         mailMessage.Attachments.Add(attach);
  114.                         attach2 = strFileName;
  115.                     }
  116.                 }
  117.                 /* Attachment-3 Repeat previous steps  */
  118.                 if (inpAttachment3.PostedFile != null)
  119.                 {
  120.                     HttpPostedFile attFile = inpAttachment3.PostedFile;
  121.                     int attachFileLength = attFile.ContentLength;
  122.                     if (attachFileLength > 0)
  123.                     {
  124.                         strFileName = Path.GetFileName(inpAttachment3.PostedFile.FileName);
  125.                         inpAttachment3.PostedFile.SaveAs(Server.MapPath(strFileName));
  126.                         MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
  127.                         mailMessage.Attachments.Add(attach);
  128.                         attach3 = strFileName;
  129.                     }
  130.                 }
  131.  
  132.                 /* Set the SMTP server and send the email with attachment */
  133.  
  134.                 // SmtpMail.SmtpServer = "127.0.0.1";
  135.                 SmtpMail.SmtpServer.Insert(0, "127.0.0.1");
  136.                 //SmtpMail.SmtpServer.Insert(0,"192.168.1.7");
  137.                 SmtpMail.Send(mailMessage);
  138.  
  139.                 /* Delete the attachements if any */
  140.                 if (attach1 != null)
  141.                     File.Delete(Server.MapPath(attach1));
  142.                 if (attach2 != null)
  143.                     File.Delete(Server.MapPath(attach2));
  144.                 if (attach3 != null)
  145.                     File.Delete(Server.MapPath(attach3));
  146.  
  147.                 /* clear the controls */
  148.                 txtSender.Text = "";
  149.                 txtReceiver.Text = "";
  150.                 txtCc.Text = "";
  151.                 txtBcc.Text = "";
  152.                 txtSubject.Text = "";
  153.                 txtBody.Text = "";
  154.  
  155.                 /* Dispaly a confirmation message to the user. */
  156.                 lblMessage.Visible = true;
  157.                 lblMessage.ForeColor = Color.Black;
  158.                 lblMessage.Text = "Message Sent.";
  159.             }
  160.             catch (Exception ex)
  161.             {
  162.                 /* Print a message informing the 
  163.                 user about the exception that was risen */
  164.                 lblMessage.Visible = true;
  165.                 lblMessage.ForeColor = Color.Red;
  166.                 lblMessage.Text = ex.ToString();
  167.             }
  168.         }
  169.     }
  170. }
  171.  
please have a look,please help me
Apr 3 '08 #1
3 2376
Plater
7,872 Expert 4TB
raj200809, I deleted your duplicate post.
Please don't double post your questions it's against the posting guidelines
MODERATOR



Now, I don't see anywhere were you supplied your credentials for your SMTP server, some servers will reject you if you don't supply valid(or any) credentials.
Also, are you sure you have a mail server running on localhost or that other LAN IP?
Apr 3 '08 #2
raj200809, I deleted your duplicate post.
Please don't double post your questions it's against the posting guidelines
MODERATOR



Now, I don't see anywhere were you supplied your credentials for your SMTP server, some servers will reject you if you don't supply valid(or any) credentials.
Also, are you sure you have a mail server running on localhost or that other LAN IP?
Your are right but its also not working in localhost due to symentic antivirus.
but when i change mail setting of symentic antivirus. its give me message .
mail send. but i m not recive mail in to address.

if any one have mail method code to send mail please give me the method. i want call the function on button click event and send a confirmation mail to client.

please help me
Apr 7 '08 #3
Plater
7,872 Expert 4TB
Add your credentials for the SMTP server and see what happens.
Apr 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: murph | last post by:
Hi , I have created a little script that is running as daemon ( it is hard to say as daemon :)) ) . Then i try to send a mail and the mail is refused from sendmail. I have no idea why it...
7
by: Rajani | last post by:
Hello, dim receiptto receiptto="a2z@yahoo.com" set cdoconfig=CreateObject("CDO.configuration") set cdomsg=CreateObject("CDO.Message") with cdoconfig.Fields...
9
by: B-Dog | last post by:
I've built a small app that sends mail through our ISP's SMTP server but when I try to send through my local exchange server I get CDO error. Does webmail use SMTP or does it strictly rely on...
3
by: dgiagio | last post by:
Hi, I'm creating a SMTP application and I would like to hear opinions about error handling. Currently there are two functions that communicate with the remote peer: ssize_t...
3
by: Ibrahim. | last post by:
Hello, Im getting the following error when mail is sent from ASP.NET 2.0 website. CDO.Messaging componenet is used for sending mail. " The message was not able to be transmitted to the SMTP...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
5
by: Don Quijote de Nicaragua | last post by:
Hi, everyone I try to send a simple e-mail witch this Code, but always send me a error messages: "ERROR: Failure sending mail." Thansk You. Don Quijote de Nicaragua. Elder Soto. Dim correo As...
7
by: Jason1983 | last post by:
Hello sir, When iam trying to send emails to my user accounts which are gmail id's using my application it is giving me this error. Here is the error... Server object error 'ASP 0177 : 800401f3'...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.