BP Forums
Mail Sending help - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Mail Sending help (/showthread.php?tid=650)



Mail Sending help - manishshrestha60 - 09-16-2012

Hi, BPFourms
I am working on my homework and it says that i have to make a mail sending program. I didn't online search and found this code but it doesn't work. Can some please help me?
Code:
Dim Message As New System.Net.Mail.MailMessage
Message.Subject = "test"
Message.Body = "test"
Message.From = New Net.Mail.MailAddress("my_account@gmail.com", "Derek")
With Message.To
    .Add(New Net.Mail.MailAddress("test1@gmail.com", "Derek"))
    .Add(New Net.Mail.MailAddress("test2@gmail.com", "Derek"))
End With
Dim Smtp As New System.Net.Mail.SmtpClient("smtp.gmail.com", 587)
Smtp.EnableSsl = True
Smtp.Credentials = New Net.NetworkCredential("my_gamil_account@gmail.com", "my_gmail_password")
Smtp.Send(Message)



Re: Mail Sending help - Vinwarez - 09-16-2012

I've searched on Google and found this code:
[code2=vbnet]Imports System.Net.Mail

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New Net.NetworkCredential("username@gmail.com", "password")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("YOURusername@gmail.com")
mail.To.Add("TOADDRESS")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail from GMAIL"
SmtpServer.Send(mail)
MsgBox("mail send")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class[/code2]

If you read the code, it's pretty much self-explanatory. You need to replace some stuff with your e-mail, password etc.


Re: Mail Sending help - manishshrestha60 - 09-16-2012

Vinwarez Wrote:I've searched on Google and found this code:
[code2=vbnet]Imports System.Net.Mail

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New Net.NetworkCredential("username@gmail.com", "password")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("YOURusername@gmail.com")
mail.To.Add("TOADDRESS")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail from GMAIL"
SmtpServer.Send(mail)
MsgBox("mail send")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class[/code2]

If you read the code, it's pretty much self-explanatory. You need to replace some stuff with your e-mail, password etc.
got this error
[Image: e823yg.png]


Re: Mail Sending help - brco900033 - 09-16-2012

Maybe you could try this one:

[code2=vbnet]Dim MyMailMessage As New MailMessage()
MyMailMessage.From = New MailAddress("your email")
MyMailMessage.To.Add("to someone")
MyMailMessage.Subject = ("your subject")
MyMailMessage.Body = "your text"
Dim SMTPServer As New SmtpClient("for example for Hotmail: smtp.live.com")
SMTPServer.EnableSsl = False
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("your email", "your email password")
SMTPServer.EnableSsl = True
SMTPServer.Send(MyMailMessage)[/code2]

Hope this works for you!


Re: Mail Sending help - manishshrestha60 - 09-17-2012

brco900033 Wrote:Maybe you could try this one:

[code2=vbnet]Dim MyMailMessage As New MailMessage()
MyMailMessage.From = New MailAddress("your email")
MyMailMessage.To.Add("to someone")
MyMailMessage.Subject = ("your subject")
MyMailMessage.Body = "your text"
Dim SMTPServer As New SmtpClient("for example for Hotmail: smtp.live.com")
SMTPServer.EnableSsl = False
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("your email", "your email password")
SMTPServer.EnableSsl = True
SMTPServer.Send(MyMailMessage)[/code2]

Hope this works for you!

thanks it to I got 98 out of 100.
thanks agian


Re: Mail Sending help - brandonio21 - 09-17-2012

Nice!