Click here to Skip to main content
15,393,377 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
I need code how to add mailer in an page to sending mails automatically to as enquiry request form.

Updated 29-Jun-11 3:01am
Sergey Alexandrovich Kryukov 30-Jun-11 18:17pm
Not a question. What's the problem?

Function to send email to multiple users also you need to add code into web.config file

Public Sub SendEmail(ByVal emailAddress As String, ByVal Subject As String, ByVal Body As String)
        Dim message As New MailMessage

        Dim mf As New MailAddress("")
        'Dim mt As New MailAddress(emailAddress)
        Dim emailClient As New SmtpClient
        Dim a() As String = emailAddress.Split(";")

        Dim i As Integer
            For i = 0 To a.Length - 1
                If String.IsNullOrEmpty(a(i).ToString) = False Then
                End If

            message.From = mf
            message.IsBodyHtml = True
            message.Subject = Subject
            message.Body = Body
            emailClient.UseDefaultCredentials = True
        Catch e As Exception
        End Try

    End Sub

Here is code for webconfig

      <smtp deliveryMethod="Network" from="">
        <network host="" port="25" defaultCredentials="true"/>

you may need to add user is nam password for anthetication with smtp server
Most effective solution is to create a window service and install it at your server, if so check this link below,
Simple Windows Service Sample[^]
another solution is use Global.asax Application_OnStart, so that, as long as the web app is running, your "scheduler" is guaranteed to be running too.
check this link below
Simulate a Windows Service using ASP.NET to run scheduled jobs[^][^]
you may find this link helpful[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900