Results 1 to 2 of 2

Thread: [2005] sending email using exchange server 2003

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    [2005] sending email using exchange server 2003

    Hello,

    Does any one have any information for sending e-mail using exchange server 2003.

    I am using vs 2005 and need to be able to send e-mail from a windows application and have the exchange server send it to the destination e-mail.

    If anyone can point me in the right direction or have some information that will be a great help. I have been told that this is very difficult to do.

    Many thank for any help you can give me,

    Steve
    steve

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: [2005] sending email using exchange server 2003

    Hello,

    I managed to find some code and created 2 different methods to send e-mail smtp, and using MS Exchange Server.

    The code i used is below. But I got a warning saying that using system.web.mail is obsolete and system.net.mail is the recommended to be used instead.

    Also using the MS Exchange is very slow, i tried to send an e-mail to my hotmail and gmail account it takes more than 10 minutes to get there.

    Is there any setting on the microsoft exchange server that need to be set?

    Another quick question, is there a way to get the server name and the e-mail account automatically instead of a user inputting in? They can just click the send button.

    Many thanks for your time,

    Steve

    Code for using system.web.mail

    Code:
     Private Sub btnSendExchangeServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendExchangeServer.Click
            Dim mailMsg As New MailMessage()
    
            mailMsg.To = "[email protected]"
            mailMsg.From = "[email protected]"
            mailMsg.Subject = "2nd Microsoft Exchange Server Mail Test"
            mailMsg.Body = "This email came from MS Exchange Server"
    
            Try
                SmtpMail.SmtpServer = "something.domain.com"
                SmtpMail.Send(mailMsg)
    
            Catch ex As Net.Mail.SmtpException
                MessageBox.Show(ex.Message)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    
        End Sub
    End Class

    Code for using gmail smpt server using system.net.mail
    Code:
    Private Sub btnSendMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendMail.Click
            Dim msgTo As New MailAddress("[email protected]")
            Dim msgFrom As New MailAddress("[email protected]")
            Dim msgSender As New MailAddress("[email protected]")
    
            Dim mailMsg As New MailMessage()
            mailMsg.Sender = msgSender
            mailMsg.To.Add(msgTo)
            mailMsg.Priority = MailPriority.High
            mailMsg.CC.Add("[email protected]")
            mailMsg.Subject = "This is a mail test"
            mailMsg.Body = "This is the body of the e-mail, Enjoy"
            mailMsg.From = msgFrom
    
            Dim client As New SmtpClient("smtp.gmail.com", 587)
            client.Credentials = New System.Net.NetworkCredential("[email protected]", "password")
            client.EnableSsl = True
    
            Try
                client.Send(mailMsg)
            Catch ex As SmtpException
                MessageBox.Show(ex.Message)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    
        End Sub
    Last edited by steve_rm; Jun 6th, 2007 at 01:34 PM.
    steve

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