?
Solved

Sending Email from VB.Net via Exchange

Posted on 2003-03-16
3
Medium Priority
?
142 Views
Last Modified: 2010-05-01
I am trying to get my VB.Net application to send email via an Exchange Server, using System.Web.Mail.SmtpMail.SmtpServer

I cannot seem to get it to work.

Does anybody have any suggestions?

Regards,

Nathan
nathan@funkyrelativity.com
0
Comment
Question by:FunkyRelativity
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
Ralf Klatt earned 800 total points
ID: 8150701
Hi Funky,

I don't see what you mean ... Exchange Server OR SMTPMail ... there's a difference!

For SMTP you can try the following:


Imports System.Web.Mail

Namespace YourNamespace

     Public Class TestEmail
          Public Sub SendMyMail(ByVal mailContent As String, ByVal mailTxtFormat As Integer)
               Dim msg As New MailMessage()
               msg.To = "anyone@anydomain.com"
               msg.From = "you@yourdomain.com"
               Select Case mailTxtFormat
                    Case 1
                         msg.BodyFormat = MailFormat.Html
                    Case 2
                         msg.BodyFormat = MailFormat.Text
                    Case Else
                         msg.BodyFormat = MailFormat.Text
               End Select
               msg.Subject = "Test Mail"    
               msg.Body = mailContent          
               SmtpMail.SmtpServer = "xxx.xxx.xxx.xxx"
               SmtpMail.Send(msg)
               msg = Nothing
          End Sub
        End Class
End Namespace
               Public Sub SendAMail()                    mailContent = "Hello, " & ControlChars.CrLf & "<br><br>"
                                   mailContent += "This is a test mail!" & ControlChars.CrLf & "<br><br>"
                                   mailContent += "Best regards "                                   Dim mailer As New YourNamespace.TestEmail()
                                   mailer.SendMyMail(mailContent, 1)
                                   mailer = Nothing
                        End Sub



Hope this helps for SMTP ... for Exchange Server behavior you should refer to the CDO/.NET documentation.

Best regards, Raisor
0
 

Expert Comment

by:CleanupPing
ID: 8532244
Hi FunkyRelativity,
This old question (QID 20552987) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8956476
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Accept Raisor's comments as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question