Section 9.18. Messaging

9.18. Messaging

Messaging services (email) can be accessed using CDO (Collaborative Data Objects). This COM object contains a large and powerful selection of objects.

CDO is a powerful but complex object model. The web site, CDO Live, at http://www.cdolive.com, is an excellent resource to get you started working with CDO.

The following example will log on to your default messaging profile and send a message. This assumes you are using an Exchange or Outlook client that has been set up to send Internet email. This will not work with Outlook Express.

 Dim objSession, objMessage, WshShell, sPrf, objRecipient Set WshShell = CreateObject("WScript.Shell") 'create a MAPI session Set objSession = CreateObject("MAPI.Session") 'check if the OS string contains NT 'set the profile string. This will read your default setting sPrf = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging         Subsystem\Profiles\DefaultProfile" 'log on using the default profile name objSession.Logon WshShell.RegRead(sPrf) 'create a new message, setting the subject to Hello There Set objMessage = _         objSession.Outbox.Messages.Add("Hello There") objMessage.Text = "This is the body of the message" 'send to Joe Blow Set objRecipient = objMessage.Recipients.Add("Joe Blow", _         "SMTP:joeb@abc.com") objRecipient.Resolve 'resolve the address 'send the message objMessage.Send objSession.Logoff 



Windows XP in a Nutshell
Windows XP in a Nutshell, Second Edition
ISBN: 0596009003
EAN: 2147483647
Year: 2003
Pages: 266

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net