Visual Basic
  Home arrow Visual Basic arrow Fun with Email: VB6, CDO, MAPI, and a Remo...
Web Buyers Guide
CIO Insight
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC

Fun with Email: VB6, CDO, MAPI, and a Remote Exchange Server
By: Matt Burnett
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 64
    2003-02-16

    Table of Contents:
  • Fun with Email: VB6, CDO, MAPI, and a Remote Exchange Server
  • The MAPI Approach
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Fun with Email: VB6, CDO, MAPI, and a Remote Exchange Server
    (Page 1 of 3 )

    In this article, Matt shows us how to send emails from a VB Windows application. As CDONTS is for servers, a different approach must be used.Yesterday, I was really unhappy with my computer. The programming at hand was clear and seemed to be a straightforward deal. In the end, it was not so easy.

    The Deal: A client machine (workstation, Win98, 2000, or ME) will actively send emails from within a custom VB6 application (exe). Additionally, the application instantiated a custom local object (dll) that contained a public SendMail function with parameters to send the mail.

    I stepped through this process by first (my machine is an NT workstation with transaction server):
    • Creating a VB form in MS Visual Basic 6 to hold the Click event and Public SendMail function.
    • Transfer the Public SendMail function to a class object.
    • Compile and run, calling the function from the class.
    So easy (I thought!). I created a button to fire my SendMail function in the form (form1). I did not think that CDONTS is a server library and not available on other client types.

    Private Sub Command1_Click()
     Call blnSendMail ("burnettm@hotmail.com", "burnettm@hotmail.com", "mail", "functional")
    End Sub

    Private Function blnSendMail(strTo As String, strFrom As String, strSubject As String, strBody As String) As Boolean
     'The CDO object is located on NT server, usually with the resource kit installed, ADCSRV4 is properly configured.
     On Error Resume Next
     Dim mail As CDONTS.NewMail
     Set mail = New CDONTS.NewMail

     mail.To = strTo
     mail.From = strFrom
     mail.Subject = strSubject
     mail.Body = strBody
     mail.Send

     Set mail = Nothing

     If Err.Number <> 0 Then
      blnSendMail = False
     Else
      blnSendMail = True
     End If
    End Function


    Ok, so this script failed miserably when run on my workstation, but ran successfully on a server. However, this was not what I needed and I turned to MAPI. Now, MAPI is like an extended CDO object and is about having a ‘Profile’ setup in the "Inbox" on your computer. My next attempt, below, called a MAPI object in a VB form using an Inbox profile.

    More Visual Basic Articles
    More By Matt Burnett


     

    VISUAL BASIC ARTICLES

    - Developing an XML Web Service Using Visual S...
    - Creating an HTML File List with VB
    - Fun with Email: VB6, CDO, MAPI, and a Remote...
    - Extranet/Intranet Dictionary Cracker in VB
    - Finding Default App Icons With Visual Basic
    - Registry Fever With Visual Basic
    - Implementing An ADO Data Control With VB6
    - Printing With Visual Basic
    - MSMQ Part 1/2: Architecture and Simple Imple...
    - Magnifying The Desktop With Visual Basic
    - Sending Email With MAPI Components in Visual...
    - Two Person Chat With The Winsock Control And...
    - A Real-Time ActiveX News Control
    - Accessing the Windows API in Visual Basic






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway