Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mail Sending help
#1
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)
Support me by take tour to BPForums http://bit.ly/YTBCS1

Get More Views on youtubehttp://addm.cc/?WIZ01V
#2
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.
Also known as Rocketalypse.
System.out.println("I prefer Java.");
#3
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]
Support me by take tour to BPForums http://bit.ly/YTBCS1

Get More Views on youtubehttp://addm.cc/?WIZ01V
#4
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!
#5
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
Support me by take tour to BPForums http://bit.ly/YTBCS1

Get More Views on youtubehttp://addm.cc/?WIZ01V
#6
Nice!
My Blog | My Setup | My Videos | Have a wonderful day.


Forum Jump:


Users browsing this thread: 1 Guest(s)