472,958 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 2349
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'...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.