Using Email to Register a User

It's becoming common to let users register their software with the manufacturers online. One way of doing that is through email, where all the details are hidden from users; all they have to do is to click a menu item. Let's add that menu item and give it the caption Register Now and the name Register; place it in the eMailer Help menu like this:

Open the new menu item's click event handler:

Private Sub Register_Click()
End Sub

In this event handler, we'll compose our own email message and send it without the user's intervention. We begin by starting a new MAPI session as we have done before:

Private Sub Register_Click()
—> MAPISession1.SignOn
—> If Err <> 0 Then
—>     MsgBox "Logon Failure: " + Error$
—> End If
               .
               .
               .
End Sub

Next, we pass the MAPI session ID to the MAPIMessages control:

Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
  —>   MAPIMessages1.SessionID = MAPISession1.SessionID
               .
               .
               .
End Sub

Now we're ready to compose the new message; we start by setting MAPIMessages1's MsgIndex property to –1, as we did before, and calling the Compose method:

Private Sub Register_Click()
    MAPISession1.SignOn

If Err <> 0 Then

MsgBox "Logon Failure: " + Error$
    End If
        MAPIMessages1.SessionID = MAPISession1.SessionID
—>     MAPIMessages1.MsgIndex = -1
—>     MAPIMessages1.Compose
                .
                .
                .
End Sub

At this point, we're ready to address our email message. We use the MAPIMessages RecipDisplayName and RecipAddress properties. The RecipAddress property holds the email address where we will send our message. The RecipDisplayName property holds the name of the recipient. We will use the same entry ("VBISoft@server.com") for both properties:

Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
        MAPIMessages1.SessionID = MAPISession1.SessionID
        MAPIMessages1.MsgIndex = -1
        MAPIMessages1.Compose
—>     MAPIMessages1.RecipDisplayName = "VBISoft@server.com"
—>     MAPIMessages1.RecipAddress = "VBISoft@server.com"
                .
                .
                .
End Sub

If the recipient's name appears in the Microsoft Exchange address book, you can have it converted to an email address using the AddressResolveUI property and the ResolveName method. (You can place entries in the address book by selecting the Address Book item of Microsoft Exchange's Tools menu.) We set these properties here (although they are not needed, because we have set the email address) to show how to use them. We set AddressResolveUI to True to have Microsoft Exchange resolve the name from the address book, and we call the ResolveName method:

Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
        MAPIMessages1.SessionID = MAPISession1.SessionID
        MAPIMessages1.MsgIndex = -1
        MAPIMessages1.Compose
        MAPIMessages1.RecipDisplayName = "VBISoft@server.com"
        MAPIMessages1.RecipAddress = "VBISoft@server.com"
 —>    MAPIMessages1.AddressResolveUI = True
 —>    MAPIMessages1.ResolveName
              .
              .
              .
End Sub

Now we set the subject line of our email to "Registering" by setting the MsgSubject property this way:

Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
        MAPIMessages1.SessionID = MAPISession1.SessionID
        MAPIMessages1.MsgIndex = -1
        MAPIMessages1.Compose
        MAPIMessages1.RecipDisplayName = "VBISoft@server.com"
        MAPIMessages1.RecipAddress = "VBISoft@server.com"
        MAPIMessages1.AddressResolveUI = True
        MAPIMessages1.ResolveName
  —>   MAPIMessages1.MsgSubject = "Registering"
              .
              .
              .
End Sub
When we get the email, the Subject line will read "Registering." Next, we set the text of the message using the MsgNoteText property. We set the text to "Normal Registration Message":
Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$

End If

MAPIMessages1.SessionID = MAPISession1.SessionID
        MAPIMessages1.MsgIndex = -1
        MAPIMessages1.Compose
        MAPIMessages1.RecipDisplayName = "VBISoft@server.com"
        MAPIMessages1.RecipAddress = "VBISoft@server.com"
        MAPIMessages1.AddressResolveUI = True
        MAPIMessages1.ResolveName
        MAPIMessages1.MsgSubject = "Registering"
  —>   MAPIMessages1.MsgNoteText = "Normal Registration Message"
              .
              .
              .
End Sub

The email message is ready to send. We use the Send method, also closing the MAPI session with SignOff:

Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
        MAPIMessages1.SessionID = MAPISession1.SessionID
        MAPIMessages1.MsgIndex = -1
        MAPIMessages1.Compose
        MAPIMessages1.RecipDisplayName = "VBISoft@server.com"
        MAPIMessages1.RecipAddress = "VBISoft@server.com"
        MAPIMessages1.AddressResolveUI = True
        MAPIMessages1.ResolveName
        MAPIMessages1.MsgSubject = "Registering"
        MAPIMessages1.MsgNoteText = "Normal Registration Message"
  —>   MAPIMessages1.Send
  —>   MAPISession1.SignOff
End Sub

And that's it—now we can send registration email with the click of the mouse. The code for our eMailer project appears in Listing 4.1.

Listing 4.1 (eMailer) frmMain.frm

VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Object = "{20C62CAE-15DA-101B-B9A8-444553540000}#1.1#0"; "MSMAPI32.OCX"
Begin VB.Form frmMain
   Caption         =   "eMailer"
   ClientHeight    =   3195
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin ComctlLib.Toolbar tbToolBar
      Align           =   1  'Align Top
      Height          =   1080
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   4680
      _ExtentX        =   8255
      _ExtentY        =   1905
      Appearance      =   1
      ImageList       =   "imlIcons"
      BeginProperty Buttons {7791BA41-E020-11CF-8E74-00A0C90F26F8}
         NumButtons      =   17
         BeginProperty Button1 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "New"
            Object.ToolTipText     =   "New"
            Object.Tag             =   ""
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Open"
            Object.ToolTipText     =   "Open"
            Object.Tag             =   ""
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Save"
            Object.ToolTipText     =   "Save"
            Object.Tag             =   ""
            ImageIndex      =   3

EndProperty

BeginProperty Button4 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   ""
            Object.Tag             =   ""
            Style           =   3
         EndProperty
         BeginProperty Button5 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Print"
            Object.ToolTipText     =   "Print"
            Object.Tag             =   ""
            ImageIndex      =   4
         EndProperty
         BeginProperty Button6 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   ""
            Object.Tag             =   ""
            Style           =   3
         EndProperty
         BeginProperty Button7 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Cut"
            Object.ToolTipText     =   "Cut"
            Object.Tag             =   ""
            ImageIndex      =   5
         EndProperty
         BeginProperty Button8 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Copy"
            Object.ToolTipText     =   "Copy"
            Object.Tag             =   ""
            ImageIndex      =   6
         EndProperty
         BeginProperty Button9 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Paste"
            Object.ToolTipText     =   "Paste"
            Object.Tag             =   ""
            ImageIndex      =   7
         EndProperty
         BeginProperty Button10 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   ""
            Object.Tag             =   ""
            Style           =   3
         EndProperty
         BeginProperty Button11 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Bold"
            Object.ToolTipText     =   "Bold"
            Object.Tag             =   ""
            ImageIndex      =   8
         EndProperty
         BeginProperty Button12 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Italic"
            Object.ToolTipText     =   "Italic"
            Object.Tag             =   ""
            ImageIndex      =   9
         EndProperty
         BeginProperty Button13 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Underline"
            Object.ToolTipText     =   "Underline"
            Object.Tag             =   ""
            ImageIndex      =   10
         EndProperty
         BeginProperty Button14 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   ""
            Object.Tag             =   ""
            Style           =   3
         EndProperty
         BeginProperty Button15 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Left"
            Object.ToolTipText     =   "Left Justify"
            Object.Tag             =   ""
            ImageIndex      =   11
         EndProperty
         BeginProperty Button16 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Center"
            Object.ToolTipText     =   "Center"
            Object.Tag             =   ""
            ImageIndex      =   12
         EndProperty
         BeginProperty Button17 {7791BA43-E020-11CF-8E74-00A0C90F26F8}
            Key             =   "Right"
            Object.ToolTipText     =   "Right Justify"
            Object.Tag             =   ""
            ImageIndex      =   13
         EndProperty
      EndProperty
      MouseIcon       =   "frmMain.frx":0000
   End
   Begin ComctlLib.StatusBar sbStatusBar
      Align           =   2  'Align Bottom
      Height          =   270
      Left            =   0
      TabIndex        =   0
      Top             =   2925
      Width           =   4680
      _ExtentX        =   8255
      _ExtentY        =   476
      SimpleText      =   ""
      BeginProperty Panels {2C787A51-E01C-11CF-8E74-00A0C90F26F8}
         NumPanels       =   3
         BeginProperty Panel1 {2C787A53-E01C-11CF-8E74-00A0C90F26F8}

AutoSize = 1

Object.Width           =   2619
            MinWidth        =   2540
            Text            =   "Status"
            TextSave        =   "Status"
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel2 {2C787A53-E01C-11CF-8E74-00A0C90F26F8}
            Style           =   6
            AutoSize        =   2
            Object.Width           =   2540
            MinWidth        =   2540
            TextSave        =   "12/4/96"
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel3 {2C787A53-E01C-11CF-8E74-00A0C90F26F8}
            Style           =   5
            AutoSize        =   2
            Object.Width           =   2540
            MinWidth        =   2540
            TextSave        =   "2:37 PM"
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      MouseIcon       =   "frmMain.frx":001C
   End
   Begin MSComDlg.CommonDialog dlgCommonDialog
      Left            =   1740
      Top             =   1350
      _ExtentX        =   847
      _ExtentY        =   847
      FontSize        =   1.89257e-37
   End
   Begin InetCtlsObjects.Inet Inet1
      Left            =   2040
      Top             =   1320
      _ExtentX        =   1005
      _ExtentY        =   1005
   End
   Begin MSMAPI.MAPISession MAPISession1
      Left            =   2040
      Top             =   1320
      _ExtentX        =   1005
      _ExtentY        =   1005
      DownloadMail    =   -1  'True
      LogonUI         =   -1  'True
      NewSession      =   0   'False
   End
   Begin MSMAPI.MAPIMessages MAPIMessages1
      Left            =   2040
      Top             =   1320
      _ExtentX        =   1005
      _ExtentY        =   1005
      AddressEditFieldCount=   1
      AddressModifiable=   0   'False
      AddressResolveUI=   0   'False
      FetchSorted     =   0   'False
      FetchUnreadOnly =   0   'False
   End
   Begin ComctlLib.ImageList imlIcons
      Left            =   1740
      Top             =   1350
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      BeginProperty Images {8556BCD1-E01E-11CF-8E74-00A0C90F26F8}
         NumListImages   =   13
         BeginProperty ListImage1 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":0038
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":038A
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":06DC
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":0A2E
            Key             =   ""

EndProperty

BeginProperty ListImage5 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":0D80
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":10D2
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":1424
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":1776
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":1AC8
            Key             =   ""
         EndProperty
         BeginProperty ListImage10 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":1E1A
            Key             =   ""
         EndProperty
         BeginProperty ListImage11 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":216C
            Key             =   ""
         EndProperty
         BeginProperty ListImage12 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":24BE
            Key             =   ""
         EndProperty
         BeginProperty ListImage13 {8556BCD3-E01E-11CF-8E74-00A0C90F26F8}
            Picture         =   "frmMain.frx":2810
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Menu mnuFile
      Caption         =   "&File"
      Begin VB.Menu mnuFileNew
         Caption         =   "&New"
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuFileOpen
         Caption         =   "&Open"
         Shortcut        =   ^O
      End
      Begin VB.Menu mnuFileClose
         Caption         =   "&Close"
      End
      Begin VB.Menu mnuFileBar1
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileSave
         Caption         =   "&Save"
         Shortcut        =   ^S
      End
      Begin VB.Menu mnuFileSaveAs
         Caption         =   "Save &As..."
      End
      Begin VB.Menu mnuFileSaveAll
         Caption         =   "Save A&ll"
      End
      Begin VB.Menu mnuFileBar2
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileProperties
         Caption         =   "Propert&ies"
      End
      Begin VB.Menu mnuFileBar3
         Caption         =   "-"
      End
      Begin VB.Menu mnuFilePageSetup
         Caption         =   "Page Set&up..."
      End
      Begin VB.Menu mnuFilePrintPreview
         Caption         =   "Print Pre&view"
      End
      Begin VB.Menu mnuFilePrint
         Caption         =   "&Print..."
         Shortcut        =   ^P
      End
      Begin VB.Menu mnuFileBar4
         Caption         =   "-"
      End
      Begin VB.Menu email
         Caption         =   "Check email"
      End
      Begin VB.Menu mnuFileSend
         Caption         =   "Sen&d email..."
      End
      Begin VB.Menu mnuFileBar5
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileMRU

Caption = ""

Index           =   0
         Visible         =   0   'False
      End
      Begin VB.Menu mnuFileMRU
         Caption         =   ""
         Index           =   1
         Visible         =   0   'False
      End
      Begin VB.Menu mnuFileMRU
         Caption         =   ""
         Index           =   2
         Visible         =   0   'False
      End
      Begin VB.Menu mnuFileMRU
         Caption         =   ""
         Index           =   3
         Visible         =   0   'False
      End
      Begin VB.Menu mnuFileBar6
         Caption         =   "-"
         Visible         =   0   'False
      End
      Begin VB.Menu mnuFileExit
         Caption         =   "E&xit"
      End
   End
   Begin VB.Menu mnuEdit
      Caption         =   "&Edit"
      Begin VB.Menu mnuEditUndo
         Caption         =   "&Undo"
         Shortcut        =   ^Z
      End
      Begin VB.Menu mnuEditBar1
         Caption         =   "-"
      End
      Begin VB.Menu mnuEditCut
         Caption         =   "Cu&t"
         Shortcut        =   ^X
      End
      Begin VB.Menu mnuEditCopy
         Caption         =   "&Copy"
         Shortcut        =   ^C
      End
      Begin VB.Menu mnuEditPaste
         Caption         =   "&Paste"
         Shortcut        =   ^V
      End
      Begin VB.Menu mnuEditPasteSpecial
         Caption         =   "Paste &Special..."
      End
   End
   Begin VB.Menu mnuHelp
      Caption         =   "&Help"
      Begin VB.Menu mnuHelpContents
         Caption         =   "&Contents"
      End
      Begin VB.Menu mnuHelpSearch
         Caption         =   "&Search For Help On..."
      End
      Begin VB.Menu Register
         Caption         =   "Register Now"
      End
      Begin VB.Menu mnuHelpBar1
         Caption         =   "-"
      End
      Begin VB.Menu mnuHelpAbout
         Caption         =   "&About eMailer..."
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
Private Sub email_Click()
    MAPISession1.DownLoadMail = True
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
        MAPISession1.SignOff
End Sub
Private Sub Form_Load()
    Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
    Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
    Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)

Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)

End Sub
Private Sub Form_Unload(Cancel As Integer)
    If Me.WindowState <> vbMinimized Then
        SaveSetting App.Title, "Settings", "MainLeft", Me.Left
        SaveSetting App.Title, "Settings", "MainTop", Me.Top
        SaveSetting App.Title, "Settings", "MainWidth", Me.Width
        SaveSetting App.Title, "Settings", "MainHeight", Me.Height
    End If
End Sub
Private Sub mnuHelpAbout_Click()
    'To Do
    MsgBox "About Box Code goes here!"
End Sub
Private Sub Register_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
        MAPIMessages1.SessionID = MAPISession1.SessionID
        MAPIMessages1.MsgIndex = -1
        MAPIMessages1.Compose
        MAPIMessages1.RecipDisplayName = "VBISoft@server.com"
        MAPIMessages1.RecipAddress = "VBISoft@server.com"
        MAPIMessages1.AddressResolveUI = True
        MAPIMessages1.ResolveName
        MAPIMessages1.MsgSubject = "Registering"
        MAPIMessages1.MsgNoteText = "Normal Registration Message"
        MAPIMessages1.Send
        MAPISession1.SignOff
End Sub
Private Sub tbToolBar_ButtonClick(ByVal Button As ComctlLib.Button)
    Select Case Button.Key
        Case "New"
            mnuFileNew_Click
        Case "New"
            mnuFileNew_Click
        Case "Open"
            mnuFileOpen_Click
        Case "Save"
            mnuFileSave_Click
        Case "Print"
            mnuFilePrint_Click
        Case "Cut"
            mnuEditCut_Click
        Case "Copy"
            mnuEditCopy_Click
        Case "Paste"
            mnuEditPaste_Click
        Case "Bold"
            'To Do
            MsgBox "Bold Code goes here!"
        Case "Italic"
            'To Do
            MsgBox "Italic Code goes here!"
        Case "Underline"
            'To Do
            MsgBox "Underline Code goes here!"
        Case "Left"
            'To Do
            MsgBox "Left Code goes here!"
        Case "Center"
            'To Do
            MsgBox "Center Code goes here!"
        Case "Right"
            'To Do
            MsgBox "Right Code goes here!"
    End Select
End Sub
Private Sub mnuHelpContents_Click()
    Dim nRet As Integer
    'if there is no helpfile for this project display a message to the   
'user you can set the HelpFile for your application in the Project 
'Properties dialog
    If Len(App.HelpFile) = 0 Then
        MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
    Else
        On Error Resume Next
        nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0)

If Err Then

MsgBox Err.Description
        End If
    End If
End Sub
Private Sub mnuHelpSearch_Click()
    Dim nRet As Integer
    'if there is no helpfile for this project display a message to 
    'the user you can set the HelpFile for your application in the
    'Project Properties dialog
    If Len(App.HelpFile) = 0 Then
        MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
    Else
        On Error Resume Next
        nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0)
        If Err Then
            MsgBox Err.Description
        End If
    End If
End Sub
Private Sub mnuEditCopy_Click()
    'To Do
    MsgBox "Copy Code goes here!"
End Sub
Private Sub mnuEditCut_Click()
    'To Do
    MsgBox "Cut Code goes here!"
End Sub
Private Sub mnuEditPaste_Click()
    'To Do
    MsgBox "Paste Code goes here!"
End Sub
Private Sub mnuEditPasteSpecial_Click()
    'To Do
    MsgBox "Paste Special Code goes here!"
End Sub
Private Sub mnuEditUndo_Click()
    'To Do
    MsgBox "Undo Code goes here!"
End Sub
Private Sub mnuFileOpen_Click()
    Dim sFile As String
    With dlgCommonDialog
        'To Do
        'set the flags and attributes of the
        'common dialog control
        .Filter = "All Files (*.*)|*.*"
        .ShowOpen
        If Len(.filename) = 0 Then
            Exit Sub
        End If
        sFile = .filename
    End With
    'To Do
    'process the opened file
End Sub
Private Sub mnuFileClose_Click()
    'To Do
    MsgBox "Close Code goes here!"
End Sub
Private Sub mnuFileSave_Click()

'To Do

MsgBox "Save Code goes here!"
End Sub
Private Sub mnuFileSaveAs_Click()
    'To Do
    'Setup the common dialog control
    'prior to calling ShowSave
    dlgCommonDialog.ShowSave
End Sub
Private Sub mnuFileSaveAll_Click()
    'To Do
    MsgBox "Save All Code goes here!"
End Sub
Private Sub mnuFileProperties_Click()
    'To Do
    MsgBox "Properties Code goes here!"
End Sub
Private Sub mnuFilePageSetup_Click()
    dlgCommonDialog.ShowPrinter
End Sub
Private Sub mnuFilePrintPreview_Click()
    'To Do
    MsgBox "Print Preview Code goes here!"
End Sub
Private Sub mnuFilePrint_Click()
    'To Do
    MsgBox "Print Code goes here!"
End Sub
Private Sub mnuFileSend_Click()
    MAPISession1.SignOn
    If Err <> 0 Then
        MsgBox "Logon Failure: " + Error$
    End If
    MAPIMessages1.SessionID = MAPISession1.SessionID
    MAPIMessages1.MsgIndex = -1
    MAPIMessages1.Compose
    MAPIMessages1.Send True
    MAPISession1.SignOff
End Sub
Private Sub mnuFileMRU_Click(Index As Integer)
    'To Do
    MsgBox "MRU Code goes here!"
End Sub
Private Sub mnuFileExit_Click()
    'unload the form
    Unload Me
End Sub
Private Sub mnuFileNew_Click()
    'To Do
    MsgBox "New File Code goes here!"
End Sub

That's it for our eMailer project. As you can see, the email system that we have access to in Visual Basic is powerful, allowing us to compose, send, receive, and read email. In the next chapter, we'll turn to another powerful part of Visual Basic Internet programming: ActiveX controls.

© 1997 by Steven Holzner. All rights reserved.