Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending email

Status
Not open for further replies.

DotNetGnat

Programmer
Mar 10, 2005
5,548
0
0
IN
Hi Guys,

I have used this below script...
Code:
<script runat="server">    

   Sub btnSubmit_Click(sender as object, e as EventArgs)

		Dim objEmail as New MailMessage()
		objEmail.To = txtTo.Text
		objEmail.From = txtFrom.Text
		objEmail.Cc = txtCc.Text
		objEmail.Subject = "Test Email"
		objEmail.Body = txtName.Text & ", " &txtComments.Text
		objEmail.Priority = MailPriority.High

		SmtpMail.SmtpServer = "myservername"

		try
			SmtpMail.Send(objEMail)
			Response.Write(Your E-mail has been sent sucessfully - Thank You)
		
		catch exc as Exception
			Response.Write("Send failure: " + exc.ToString())
		End Try
    End Sub
</script>

and i am bounced back with this error:
Code:
Send failure: 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 (0x80040213): The transport failed to connect to the server. --- 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.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 ASP.Email_ascx.btnSubmit_Click(Object sender, EventArgs e) in c:\inetpub\[URL unfurl="true"]wwwroot\MyTemplate\Email.ascx:line[/URL] 19

Any ideas? Actually we use exchange server in our company for sending emails and i am not sure whether we use SMTP server or not...how do i find out?

Thanks

-DNG
 
you more than likely do...ask your exchange administrator...I'd use your SMTP IP Address as well...

also...i would use this to catch your email errors...
Code:
Catch ex As Exception
  Dim e As New Exception
  e = ex
  Do While Not e Is Nothing
   Current.Response.Write("<hr>")
   Current.Response.Write("<li><b>Message:</b> " & e.Message)
   e = e.InnerException
  Loop
  Current.Response.End()
 End Try

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Thanks for the reply. So how do i change my code to reflect both SMTPServer Name and SMTPServer IP address...Also thanks for that error exception catch code...

-DNG
 
instead of this...

SmtpMail.SmtpServer = "myservername"


use

SmtpMail.SmtpServer = "111.11.11.1"

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
How can I send email to more them 1 person at the same time. I need a code to send email to 3 different groups.

Thanks

Bilal
 
objEmail.To = txtTo.Text & ";" & group2@xxx.com & ";" & group3@xxx.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top