home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / commail / commail.frm < prev    next >
Text File  |  1998-04-02  |  2KB  |  55 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   1575
  5.    ClientLeft      =   6270
  6.    ClientTop       =   4950
  7.    ClientWidth     =   2130
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1575
  10.    ScaleWidth      =   2130
  11.    Begin VB.CommandButton Command1 
  12.       Caption         =   "GO!"
  13.       Height          =   495
  14.       Left            =   480
  15.       TabIndex        =   0
  16.       Top             =   600
  17.       Width           =   1215
  18.    End
  19. End
  20. Attribute VB_Name = "Form1"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = False
  23. Attribute VB_PredeclaredId = True
  24. Attribute VB_Exposed = False
  25. Private Sub Command1_Click()
  26. On Error GoTo error_olemsg
  27.     
  28.     ' create a session then log on, supplying username and password
  29.     Set objSession = CreateObject("MAPI.Session")
  30.     ' change the parameters to valid values for your configuration
  31.     objSession.Logon profileName:="TO DO: Place profile name here"
  32.  
  33.     ' create a message and fill in its properties
  34.     Set objMessage = objSession.Outbox.Messages.Add
  35.     objMessage.subject = "Gift of droids"
  36.     objMessage.Text = "Help us, Obi-wan. You are our only hope."
  37.  
  38.     ' create the recipient
  39.     Set objOneRecip = objMessage.Recipients.Add
  40.     objOneRecip.Name = "TO DO: Place email alias here"
  41.     objOneRecip.Type = mapiTo
  42.     objOneRecip.Resolve
  43.  
  44.     ' send the message and log off
  45.     objMessage.Send showDialog:=False
  46.     MsgBox "The message has been sent"
  47.     objSession.Logoff
  48.     GoTo end_olemsg
  49.     
  50. error_olemsg:
  51.     MsgBox "Error " & Str(Err) & ": " & Error$(Err)
  52. end_olemsg:
  53. End Sub
  54.  
  55.