Results 1 to 2 of 2

Thread: Sending email

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Sending email

    I want to send the email through asp.net where "To " email address list store in excel file. Send email to all email Id store in excel file.
    Please guide how to send the email reading all email id from excel files.

    Thanks

    asm

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Sending email

    1. Use the OLEDB.Net to read the excel file
    2. Read the Email Address into string and store them by concat with ,. Then pass the address to the email function as SendMailMessage("Me@vbf.com",ToAddress,Nothing,Subject, Body)

    3.Code to send Email
    Code:
    'Imports Statement
    System.Net.Mail;
     Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
          ' Instantiate a new instance of MailMessage
          Dim mMailMessage As New MailMessage()
    
          ' Set the sender address of the mail message
          mMailMessage.From = New MailAddress(from)
          ' Set the recepient address of the mail message
          mMailMessage.To.Add(New MailAddress(recepient))
    
          ' Check if the bcc value is nothing or an empty string
          If Not bcc Is Nothing And bcc <> String.Empty Then
             ' Set the Bcc address of the mail message
             mMailMessage.Bcc.Add(New MailAddress(bcc))
          End If
    
          ' Check if the cc value is nothing or an empty value
          If Not cc Is Nothing And cc <> String.Empty Then
             ' Set the CC address of the mail message
             mMailMessage.CC.Add(New MailAddress(cc))
          End If
    
          ' Set the subject of the mail message
          mMailMessage.Subject = subject
          ' Set the body of the mail message
          mMailMessage.Body = body
    
          ' Set the format of the mail message body as HTML
          mMailMessage.IsBodyHtml = True
          ' Set the priority of the mail message to normal
          mMailMessage.Priority = MailPriority.Normal
    
          ' Instantiate a new instance of SmtpClient
          Dim mSmtpClient As New SmtpClient()
          ' Send the mail message
          mSmtpClient.Send(mMailMessage)
       End Sub
    End Class
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width