Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code for sending feed back is given below giving error in SmtpMail.Send(objMM) PLEASE HELP ME TO RECTIFY ERROR

VB
<% @Import Namespace="System.Web.Mail" %>
<%@ Page Language="vb" Debug="true" %>
<script  runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

  Dim objMM as New MailMessage()

ojMM.To = "janardan.ind@gmail.com"
  objMM.From = "janardan.jsr@gmail.com"

    objMM.BodyFormat = MailFormat.Text
  
  objMM.Priority = MailPriority.High


  objMM.Subject = " Feedback "

    objMM.Body = "At " + DateTime.Now + " feedback was sent from an ASP.NET " & "Web page.  Below you will find the feedback message " & "send by " & txtName.Text & "." & vbCrLf & vbCrLf & "------" & vbCrLf & vbCrLf & txtMessage.Text & vbCrLf

  SmtpMail.SmtpServer = "127.0.0.1"
  SmtpMail.Send(objMM)


  panelSendEmail.Visible = false
  panelMailSent.Visible = true
End Sub

</script>
Posted
Updated 19-Oct-11 0:34am
v2
Comments
sravani.v 19-Oct-11 6:36am    
What error you are getting?
Janardan Pandey 19-Oct-11 6:39am    
error showing in SmtpMail.Send(objMM)
P.Salini 19-Oct-11 6:37am    
what error u r getting
Janardan Pandey 19-Oct-11 6:41am    
error showing in SmtpMail.Send(objMM)
The transport failed to connect to the server.


1 solution

You can use this method
Hope it will helps
note:It is in C#
C#
public static Boolean SendingMail(string From, string To, string Subject, string Body)
   {

           try
           {
               MailMessage m = new MailMessage("yourmailid", To);
               m.Subject = Subject;
               m.Body = Body;
               m.IsBodyHtml = true;
               m.From = new MailAddress(From);

               m.To.Add(new MailAddress(To));
               SmtpClient smtp = new SmtpClient();
               smtp.Host = "mail.google.com";

               NetworkCredential authinfo = new NetworkCredential("yurid@gmail.com", "password@1");
               smtp.UseDefaultCredentials = false;
               smtp.Credentials = authinfo;
               smtp.Send(m);
               return true;




           }
           catch (Exception ex)
           {
               return false;
           }
 
Share this answer
 
v2
Comments
Janardan Pandey 19-Oct-11 6:45am    
but i am developing for a feed back form of a web site so I need not to give password in code for email id.Please help me again bethout password.
uspatel 19-Oct-11 7:22am    
you can put the password in database,web config file or in dll.

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