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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can not send mail with this code and can't see whats wrong

Status
Not open for further replies.

russellmunday

Technical User
Jul 24, 2003
87
GB
im' not trying to do something impossible here most of this code comes from the examples but when i run it it stops at the send line "smtpmail.send(mymail)"


Imports System.Web.mail

Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private Sub nmail()

'sending the email
Dim ssmtp As String
Dim sto As String
Dim ssub As String
Dim sbody As String
Dim sattach As String
Dim mymail As MailMessage = New MailMessage

ssmtp = "smtp.dsl.pipex.com"
sto = "myaddress@mydomain.com"
sbody = "Please see Attached Files"
ssub = "hello"


mymail.To = sto
mymail.Subject = ssub
mymail.Body = sbody


SmtpMail.SmtpServer = "smtp.dsl.pipex.com"
SmtpMail.Send(mymail)


End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Call nmail()

End Sub
End Class
 
when i run it it stops at the send line "smtpmail.send(mymail)
Then what happens? My guess is that the SMTP server isn't set up correctly and eventually an error will be thrown on this line.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
when it stops thats it. The smtp server is set in the line before,
SmtpMail.SmtpServer = "smtp.dsl.pipex.com
 
Try sending mail via, say Outlook, using that same Smtp server. Let us know whether that works or not.

__________________________________________
Try forum1391 for lively discussions
 
problem resolved just needed to put a from line in and all ok
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top