The Big Red Toolbox

MGCEMail

Access the Mail files

October 24, 1999

© NSB Corporation. All rights reserved.


MGCEMail - Windows CE Custom Control Object
Written by Mark Gamber, October 1999

NS Basic is (c) NS Basic Corporation
Windows CE is (c) Microsoft Corporation

MGCEMail provides mail store access to Windows CE applications capable of making use of COM oriented controls such as NS Basic. Included in this package are:

Object Creation

AddObject "MGCEMail.Mail", "Name"

Samples


AllFolders A read-only property which returns an array of folder identification numbers. These numbers are only meaningful to the mail store.

arrFolders = Mail.AllFolders

AllServices AllServices is a read-only property that returns an array of service names. Passive services such as "Windows CE Inbox Service" are not included. If there are no direct services (non-passive), AllServices will throw an error which is easily trapped with On Error Resume Next.

arrServices = Mail.AllServices

BCC Set and retrieve blind CC addresses attached to a message.

Mail.BCC = "blindCC© whatever.com" sBCC = Mail.BCC

CC Set and retrieve CC addresses attached to a message.

Mail.CC = "tosomeoneelse© whatever.com" sCC = Mail.CC

Date Set and retrieve the date attached to a message.

Mail.Date = Now() d = Mail.Date

Error Retrieve the last error code from the mail subsystem. This is a read-only property.

iErr = Mail.Error

ErrorMsg Retrieve the last error in the form of a descriptive string from the mail subsystem using this read-only property.

MsgBox Mail.ErrorMsg

Folder Set and retrieve the current folder in use. A folder is identified by its numeric value as returned by the AllFolders property. There are also "stock" folders which exist on all devices and have fixed identifiers. These are:

Inbox: 254 Output: 253 Sent: 252
Mail.Folder = 254
cFolder = Mail.Folder

FolderMessages A read-only property which returns an array of numeric identifiers, one for each message contained within a folder. Set the Folder property before calling this property to determine from which folder to retrieve message IDs.

arrMessages = Mail.FolderMessages

FolderName Retrieve the name of a folder based on its identifier using this read-only property.

sName = Mail.FolderName( 254 )

Message Set and retrieve the body of a message.

Mail.Message = "Mail text goes here." s = Mail.Message

Recipient Set and retrieve addresses of recipients attached to a message.

Mail.Recipient = "sendto© whatever.com" sSendTo = Mail.Recipient

Sender Set and retrieve the address of a message's sender.

Mail.Sender = "fromme© whatever.com" sSender = Mail.Sender

Service Set and retrieve the name of a mail service through which a message is sent. Valid service names may be obtained by calling the AllServices property.

Mail.Service = sServices( 0 )

Subject Set and retrieve the subject line attached to a message.

Mail.Subject = "Better living through employee theft!"
sSubj = Mail.Subject

Version Retrieve the version of the MGCEMail object.

v = Mail.Version


Methods

Clear Initializes the Sender, Recipient, CC, BCC, Subject, Message, Service and Folder properties.

Mail.Clear

Close Closes an open mail object.

Mail.Close

CreateFolder CreateFolder creates a new folder in the message store. The return value is the numeric identifier of the newly created folder.

iID = Mail.CreateFolder( "New Folder" )

DeleteFolder DeleteFolder removes a folder from the message store, the folder identified by its numeric identifier. Note that you cannot delete system folders such as Inbox and Outbox.

Mail.DeleteFolder 0

DeleteMessage Remove a message from the message store, the message identified by its numeric identifier.

Mail.DeleteMessage arraymsg( i )

Move Move a message to a folder. The message is identified by its numeric identifier and the target folder is identified by setting the Folder property before calling the Move method.

Mail.Move 253

Open Open the mail object. This is required before performing any other operation on the message store.

Mail.Open

ReadMessage ReadMessage obtains various header data items and the message body from a message and sets the Sender, Recipient, CC, BCC, Subject, Message, Service and Folder properties based on the read message. Use these properties to obtain the message data after calling ReadMessage. The message to read is identified by its numeric identifier as returned by the FolderMessages property.

Mail.ReadMessage arrMsgs( i )

WriteMessage This method takes the Sender, Recipient, CC, BCC, Subject, Message, Folder and Service properties and constructs a message from that data. Unused properties are not included in the message. The finished message is added to the folder identified by the Folder property and the return value of this method is the ID of the newly created message. Note that writing a message does not mean the message is actually sent anywhere, only that it is added to the mail store.

iID = Mail.WriteMessage


Events

MGCEMail does not support events.

Change Log