email sending using exchange server 2003 and VS 2005
-
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
-
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
first you need to import this mail class Imports System.Web.Mail Dim mail As New MailMessage mail.To = anyone@someDomain mail.From = user@yourDomain mail.Subject = "message subject comes here" mail.Body = "body of the message.. could be from a textbox" SmtpMail.SmtpServer = "MailServerName" 'your real server name goes here SmtpMail.Send(mail) ' this section is what sends the mail... this is perfectly fine....i have use it.. the from email account..must exist on the exchange mail server account.. so if you have an account on that server.. use it for the from section or just create a temp account to be used for this purpose.. hope this helps..
Nab
-
first you need to import this mail class Imports System.Web.Mail Dim mail As New MailMessage mail.To = anyone@someDomain mail.From = user@yourDomain mail.Subject = "message subject comes here" mail.Body = "body of the message.. could be from a textbox" SmtpMail.SmtpServer = "MailServerName" 'your real server name goes here SmtpMail.Send(mail) ' this section is what sends the mail... this is perfectly fine....i have use it.. the from email account..must exist on the exchange mail server account.. so if you have an account on that server.. use it for the from section or just create a temp account to be used for this purpose.. hope this helps..
Nab
Hello, Thanks for your help. 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
Private Sub btnSendExchangeServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendExchangeServer.Click Dim mailMsg As New MailMessage() mailMsg.To = "steve@clarityform.com" mailMsg.From = "steve@clarityform.com" mailMsg.Subject = "2nd Microsoft Exchange Server Mail Test" mailMsg.Body = "This email came from MS Exchange Server" Try SmtpMail.SmtpServer = "cf01.clarityforms.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.mailPrivate Sub btnSendMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendMail.Click Dim msgTo As New MailAddress("steve@clarityforms.com") Dim msgFrom As New MailAddress("steve@clarityforms.com") Dim msgSender As New MailAddress("steve@clarityforms.com") Dim mailMsg As New MailMessage() mailMsg.Sender = msgSender mailMsg.To.Add(msgTo) mailMsg.Priority = MailPriority.High mailMsg.CC.Add("Steve1_rm@yahoo.com") 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("steve1.rm@gmail.com", "1apple2") 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