[VB.Net]發送G-Mail模組
以GMail發縮郵件之模組
複製代碼- Imports System.Net
- Module GMail
- ''' <summary>
- ''' 透過SMTP協定發送G-Mail郵件。
- ''' </summary>
- ''' <param name="Account">用來發送郵件的帳號</param>
- ''' <param name="Password">用來發送帳號的密碼</param>
- ''' <param name="Sender">寄件者,Ex: Inndy<Inndy.mail@gmail.com></param>
- ''' <param name="Recipients">寄件者,Ex: Inndy<Inndy.mail@gmail.com></param>
- ''' <param name="Title">郵件標題</param>
- ''' <param name="Body">郵件內容</param>
- ''' <remarks></remarks>
- Public Sub SendGMail(ByVal Account As String, ByVal Password As String, ByVal Sender As String, ByVal Recipients As String, ByVal Title As String, ByVal Body As String)
- Dim MySmtp As New System.Net.Mail.SmtpClient("smtp.gmail.com", 587)
- MySmtp.Credentials = New System.Net.NetworkCredential(Account, Password)
- MySmtp.EnableSsl = True
- MySmtp.Send(Sender, Recipients, Title, Body)
- End Sub
- End Module
使用範例:
- SendGMail("123.mail@gmail.com", "Password", "HAHAHA", "1234567635@kimo.com", "測試郵件標題", "郵件內容")
留言
張貼留言