Here is the detailed error coming...
***********************************************************************
System.Exception: Error sending mail ---> System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020F): The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for hr@infonetco.com --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj, String methodName, Object[] args) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at WebApplication2.postresume.Page_Posted() in D:\Inetpub\wwwroot\WebApplication2\postresume.aspx.vb:line 145 --- End of inner exception stack trace --- at WebApplication2.postresume.Page_Posted() in D:\Inetpub\wwwroot\WebApplication2\postresume.aspx.vb:line 147 at WebApplication2.postresume.Page_Load(Object sender, EventArgs e) in D:\Inetpub\wwwroot\WebApplication2\postresume.aspx.vb:line 45
*********************************************************************
This is my VB.NET code ::
**********************************************************************
Dim message As String
Dim lfilepath As String
Dim mail As New MailMessage()
'Dim mail
'mail = Server.CreateObject("CDONTS.mail")
Dim AttachmentPath As String
Try
AttachmentPath = UploadFile()
Catch exp As Exception
Response.Write("Error Uploading File. Please report this Error to the administrator")
Response.End()
End Try
mail.BodyFormat = MailFormat.Html
message = " Name= " & txtName.Text & " " _
& "Contact Address = " & txtContactAddr.Text & " " _
& "Qualification = " & txtQual.Text & " "
mail.From = "hr@infonetco.com"
mail.To = "hr@infonetco.com"
mail.Subject = "Resume From " & txtName.Text
mail.Body = message
mail.BodyFormat = MailFormat.Html
'lfilepath = path.Text
If AttachmentPath = "" Then
Throw New Exception("No attachments...")
Else
mail.Attachments.Add(New MailAttachment(AttachmentPath, MailEncoding.Base64))
End If
Try
'Set the SMTP server name
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(mail)
Catch exp As Exception
Throw New Exception("Error sending mail", exp)
End Try
End Sub
********************************************************************