2
Answers

send Email to multiple users using exhchange

Photo of ToBe

ToBe

11y
980
1
Hi every one

I have one application have multiple users I need to send them an email using my exchange server "dtreExhcange server"  this is my code

Sub SendSimpleMail(ByVal toEmailAddress As String)


        '======================================
        Dim mail As New MailMessage()
        Dim msgBody As String
        Dim smtp As New SmtpClient

     
        mail.From = New MailAddress("me@dt.org")
        msgBody = txtEmailBody.Text
        mail.To.Add(toEmailAddress)
        mail.Subject = Subject.Text
        mail.Body = msgBody
        mail.IsBodyHtml = True

        smtp.Host = "dtreExhcange.dt.org"
        smtp.Port = 25
        smtp.EnableSsl = True
        smtp.Credentials = New System.Net.NetworkCredential("me@dt.org", "123")

        Try
            smtp.Send(mail)
            mail.Attachments.Dispose()
            MsgBox("Thank You your Message has been sent.")

        Catch x As Exception
            If x.Message.ToString = "Failure sending mail." Then
                MsgBox("Please check your Internet Connection and try again", MsgBoxStyle.Information)
            Else
                MsgBox("Failed to Send", MsgBoxStyle.Exclamation)
            End If

        End Try



    End Sub

but it's not working it will not connect to the exchange server.

can you help me on that .


Answers (2)

1
Photo of Manav Pandya
NA 7.1k 24.1k 7y
Hello hemal
 
After observing you error i would suggest :
 
- Check connection string 
- Check version of sql server you are using , and download add-in for the same
 
Still if u need more help , go to :
 
https://www.mssqltips.com/sqlservertip/2694/getting-started-with-sql-server-2012-express-localdb/
 
Thanks 
 
 
Accepted