C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Email »

Sending Email to multiple users using VB.net


Posted Date: 05 Jun 2009    Resource Type: Code Snippets    Category: Email
Author: Dharmendra KumarMember Level: Gold    
Rating: 1 out of 5Points: 7



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


Attachments

  • VB.NET EMAIL (28876-5625-SendMailToNewUser.vb.txt)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Vb.net email code  .  Vb.net email  .  Source code for sending multiple user email  .  Send to all  .  Email to multiple user  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Easy Way to send mail through ASP.Net & C#.Net
    Previous Resource: Send Email From C#
    Return to Discussion Resource Index
    Post New Resource
    Category: Email


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use