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 (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-04-03  |  1.6 KB  |  48 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. Attribute VB_Name = "Form1"
  20. Attribute VB_GlobalNameSpace = False
  21. Attribute VB_Creatable = False
  22. Attribute VB_PredeclaredId = True
  23. Attribute VB_Exposed = False
  24. Private Sub Command1_Click()
  25. On Error GoTo error_olemsg
  26.     ' create a session then log on, supplying username and password
  27.     Set objSession = CreateObject("MAPI.Session")
  28.     ' change the parameters to valid values for your configuration
  29.     objSession.Logon profileName:="TO DO: Place profile name here"
  30.     ' create a message and fill in its properties
  31.     Set objMessage = objSession.Outbox.Messages.Add
  32.     objMessage.subject = "Gift of droids"
  33.     objMessage.Text = "Help us, Obi-wan. You are our only hope."
  34.     ' create the recipient
  35.     Set objOneRecip = objMessage.Recipients.Add
  36.     objOneRecip.Name = "TO DO: Place email alias here"
  37.     objOneRecip.Type = mapiTo
  38.     objOneRecip.Resolve
  39.     ' send the message and log off
  40.     objMessage.Send showDialog:=False
  41.     MsgBox "The message has been sent"
  42.     objSession.Logoff
  43.     GoTo end_olemsg
  44. error_olemsg:
  45.     MsgBox "Error " & Str(Err) & ": " & Error$(Err)
  46. end_olemsg:
  47. End Sub
  48.