Imports Microsoft.VisualBasic Imports System Imports System.Data Imports System.Configuration Imports System.Collections Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports System.Net.Mail
Public Class SendMailToNewUser Public Shared Function SendMail(ByVal toList As String, ByVal from As String, ByVal ccList As String, ByVal subject As String, ByVal body As String) As String Dim message As New MailMessage() Dim smtpClient As New SmtpClient() Dim msg As String = String.Empty Try Dim fromAddress As New MailAddress(from) message.From = fromAddress Dim temp As String()
temp = toList.Split(";")
For Each id As String In temp
If id <> "" Then message.To.Add(id) End If
Next
'message.[To].Add(toList) If ccList <> Nothing AndAlso ccList <> String.Empty Then message.CC.Add(ccList) End If message.Subject = subject message.IsBodyHtml = True
message.Body = body smtpClient.Host = "pkpmail.patni.com" smtpClient.Port = 25 smtpClient.UseDefaultCredentials = True smtpClient.Credentials = New System.Net.NetworkCredential("username", "password") ' for patni username=you intranet user name, password = your intranet password, for other write username@emailprovidername like abc@gmail.com etc. smtpClient.Send(message) msg = "Successful" Catch ex As Exception msg = ex.Message End Try Return msg End Function End Class
AttachmentsVB.NET EMAIL (28876-5625-SendMailToNewUser.vb.txt)
|
No responses found. Be the first to respond and make money from revenue sharing program.
|