modeza
asked on
Send email in VB.NET 2005
Hi experts.. I hope you guys can help me with this issue.. Thanks in advance.
In the event click of my command button.. I'd like to send an email... I tried this:
Imports System.Net.Mail.MailMessag e (this line I put it in the first row)
Protected Sub btnsend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsend.Click
Try
Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMessage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMessage "from@emailaddress", "to@emailaddress", "Test", "TEST2")
MsgBox("You request was sent, thanks")
Dim mailClient As New Net.Mail.SmtpClient("Here goes the IP server", 25)
Catch ex As Exception
End Try
End Sub
Am I doing something wrong?? Could you tell me what is the best way to send a confirmation mail.. in VB.NET 2005.. please...
Thanks :)
In the event click of my command button.. I'd like to send an email... I tried this:
Imports System.Net.Mail.MailMessag
Protected Sub btnsend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsend.Click
Try
Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMessage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMessage "from@emailaddress", "to@emailaddress", "Test", "TEST2")
MsgBox("You request was sent, thanks")
Dim mailClient As New Net.Mail.SmtpClient("Here goes the IP server", 25)
Catch ex As Exception
End Try
End Sub
Am I doing something wrong?? Could you tell me what is the best way to send a confirmation mail.. in VB.NET 2005.. please...
Thanks :)
Here's your code, you just needed to add a call to the Send method:
Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMessage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMessage _
("from@emailaddress", "to@emailaddress", "Test", "TEST2")
Dim mailClient As New Net.Mail.SmtpClient(IPAddr ess)
mailClient.Send(emailMessa ge)
MsgBox("You request was sent, thanks")
Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMessage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMessage _
("from@emailaddress", "to@emailaddress", "Test", "TEST2")
Dim mailClient As New Net.Mail.SmtpClient(IPAddr
mailClient.Send(emailMessa
MsgBox("You request was sent, thanks")
ASKER
It doesnt send the email...
something else.. that can help ???
thanks
something else.. that can help ???
thanks
Well, what kind of problem are you having?
Make sure you change "IPAddress" to the name of your email server, or the IP address.
Make sure you change "IPAddress" to the name of your email server, or the IP address.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
is your server accepting relay?
see http://www.emoreau.com/Entries/Articles/2007/09/Using-SystemNetMail.aspx
see http://www.emoreau.com/Entries/Articles/2007/09/Using-SystemNetMail.aspx
Hi
Just check this, you can get complete idea about how to send the mail.
http://www3.sendthisfile.com/d.jsp?t=JchZ4sux2LfyobQ6WEng8OXS
Just check this, you can get complete idea about how to send the mail.
http://www3.sendthisfile.com/d.jsp?t=JchZ4sux2LfyobQ6WEng8OXS
ASKER
Thank you vadim63 ITS WORKING :)
You're awesome
You're awesome
Glad to help.
What Happen If We Have Exchange server
Public Sub SendEmail(ByVal Sender As String, ByVal Recipient As String, _
ByVal Subject As String, ByVal Body As String)
Dim smtp As New Net.Mail.SmtpClient("1.30.
'separate recipients by comma
smtp.Send(Sender, Recipient.Replace(";", ","), Subject, Body)
smtp = Nothing
End Sub