我有一个基本的vb.net Windows窗体应用程序,并想知道如何发送电子邮件?我没有设置任何服务器或类似的东西,我想知道我是否仍然可以发送它而不设置所有的东西。这是我现在的代码:
Private Sub sendEmail(ByVal golfersTable As DataTable)
'create the mail message
Dim mail As New MailMessage()
Dim SMTP As New SmtpClient()
'set the addresses
mail.From = New MailAddress("someone@gmail.com")
mail.To.Add("someone@gmail.com")
'set the content
mail.Subject = "Golf Quotas"
mail.Body = "Golfer Name" & "-----------------------------------------------" & row.Item("Average Quota")
For Each row As DataRow In golfersTable.Rows
mail.Body = row.Item("Golfer Name") & "---------------" & row.Item("Average Quota")
Next
'set the server
SMTP.EnableSsl = True
SMTP.UseDefaultCredentials = False
SMTP.Port = "465"
'SMTP.Send(mail)
Try
SMTP.Send(mail)
MsgBox("Your Email has been sent sucessfully - Thank You")
Catch ex As Exception
MsgBox("Message Failed To Send" & ex.ToString)
End Try
End Sub
我从没有尝试过的任何东西都没有任何工作......我觉得我做错了但是没有用。我在nslookup www.gmail.com
中尝试了cammand prompt
,但它说domain not found
?
答案 0 :(得分:0)
如果您使用GMail帐户发送电子邮件,则可以使用Google的SMTP服务器smtp.gmail.com。
此处有更多详情: http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm