Problem Sending Mail

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Problem Sending Mail

 
0
  #1
Nov 27th, 2008
Hi!

This is the code I have for sending mail-

  1.  
  2. Imports System.Web.Mail
  3.  
  4. Public Class Form1
  5.  
  6.  
  7.  
  8.  
  9. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  10.  
  11. End Sub
  12.  
  13. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  14. Dim Mailmsg As New System.Web.Mail.MailMessage()
  15. SmtpMail.SmtpServer = "mysmtpserver"
  16. Mailmsg.To = "recepient@domain.com"
  17.  
  18. Mailmsg.From = "\" & "foo" & "\ <" & "bar@domain.com" & ">"
  19. Mailmsg.Subject = "Sending a test mail"
  20.  
  21. 'Mail Body
  22. Mailmsg.Body = "This is a test message"
  23.  
  24. Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
  25. Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "myusername") 'set your username here
  26. Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "mypassword") 'set your password here
  27. Mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "26") 'Put port number here
  28.  
  29.  
  30.  
  31.  
  32. Try
  33. SmtpMail.Send(Mailmsg)
  34. Catch ex As Exception
  35. 'MsgBox(ex.ToString)
  36. Me.TextBox1.Text = ex.ToString
  37. End Try
  38.  
  39.  
  40.  
  41. End Sub
  42. End Class


The error message I get is-

System.Web.HttpException: The transport failed to connect to the server.
---> 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 bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at MyMailer.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\tuse\AppData\Local\Temporary Projects\MyMailer\Form1.vb:line 32


---------

Tried to google, but no luck.

Any ideas?
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Problem Sending Mail

 
0
  #2
Nov 27th, 2008
If I try port 25, I get this message-

System.Web.HttpException: The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040211): The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

--- 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 bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at MyMailer.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\tuse\AppData\Local\Temporary Projects\MyMailer\Form1.vb:line 32
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: 4advanced is an unknown quantity at this point 
Solved Threads: 10
4advanced 4advanced is offline Offline
Junior Poster in Training

Re: Problem Sending Mail

 
0
  #3
Nov 27th, 2008
  1. SmtpMail.SmtpServer = "mysmtpserver"
mysmtpserver, did you stated this value for testingpurposes? It should be a real smtpserver like mail.yourcompany.com.....

Regards,
Richard
The Netherlands

[edit]
Be aware that most smtp servers don't respond on RELAY. Systemadministrators block relaying their smtp server
Last edited by 4advanced; Nov 27th, 2008 at 1:31 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Problem Sending Mail

 
0
  #4
Nov 27th, 2008
I did put valid values in the actual code I used, just did not want to post it here.

Have used a correct smtp server, username, password - sure of that
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: 4advanced is an unknown quantity at this point 
Solved Threads: 10
4advanced 4advanced is offline Offline
Junior Poster in Training

Re: Problem Sending Mail

 
0
  #5
Nov 27th, 2008
Okay, just for asking.....

Check this site, it's a good reference for programming-help. Try the simple example and if that works, extend it piece by piece.
Let me know if it worked....


http://www.systemwebmail.com/faq/2.9.aspx

AND

http://www.systemnetmail.com/


Regards
Last edited by 4advanced; Nov 27th, 2008 at 1:40 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Problem Sending Mail

 
0
  #6
Nov 27th, 2008
I guess I've specifically used this-

http://www.systemwebmail.com/faq/3.8.aspx

The server requires authentication.
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: 4advanced is an unknown quantity at this point 
Solved Threads: 10
4advanced 4advanced is offline Offline
Junior Poster in Training

Re: Problem Sending Mail

 
0
  #7
Nov 27th, 2008
It should work with the fields.add() like you mentioned before. Did you also checked if your firewall blocks ports 25? If so, port 2525 might do the job....
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Problem Sending Mail

 
0
  #8
Nov 27th, 2008
No luck with port 2525 either, have disabled my firewall too.

Any other troubleshooting steps?

Thanks a lot for your ideas.
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC