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 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:got this error 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: thanks it to I got 98 out of 100. thanks agian Re: Mail Sending help - brandonio21 - 09-17-2012 Nice! |