You can also use the Xojo OLEObject class. Except for “NameSpace” as Xojo’s Namespace (Bug and is reported) is in conflict with “Outlook.NameSpace”
From Microsoft’s link: http://msdn.microsoft.com/en-us/library/office/aa271596(v=office.11).aspx you can get an idea how to convert it to Xojo.
I made some small examples just to give you an idea how you can use the OLEObject class:
Count Folders in Outlook 2010:
Dim myOlApp As OLEObject
Dim myNameSpace As OLEObject
Dim myFolder As OLEObject
Dim myEnums as New Dictionary
Dim Count, nEnums As Integer
Dim outText As String
myEnums.Value("olFolderInbox") = 6
myEnums.Value("olFolderOutbox") = 4
myEnums.Value("olFolderContacts") = 10
myEnums.Value("olFolderSentMail") = 5
myEnums.Value("olFolderJunk") = 23
// Enumeration See: http://msdn.microsoft.com/en-us/library/office/bb208072%28v=office.12%29.aspx
myOlApp = New OLEObject("Outlook.Application")
myNameSpace = myOlApp.GetNameSpace("MAPI")
For nEnums = 0 to myEnums.Count -1
myFolder = myNameSpace.GetDefaultFolder(myEnums.Value(myEnums.key(nEnums)))
Count = myFolder.Items.count
outText = outText +myFolder.invoke("Name")+": "+str(count)+EndOfLine.Windows
Next
Msgbox(outText)
myOlApp = Nil
exception err as oleexception
msgbox err.message
Sent an email with use of Outlook:
Dim ToAddress As String
Dim MessageSubject As String
Dim MessageBody As String
//Dim MessageAttachment
Dim ol, ns, olMailItem, myRecipient As OLEObject
Dim newMail As OLEOBJECT
ToAddress = "me@address.com" ' change this...
MessageSubject = "How to use Outlook with Xojo"
MessageBody = "*BODY* email via MAPI *BODY*"
ol = New OLEObject ("Outlook.Application")
ns = ol.getNamespace("MAPI")
ns.logon "","",true,false
newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody + EndOfLine
'' validate the recipient, just in case...
myRecipient = ns.CreateRecipient(ToAddress)
myRecipient.Resolve
If Not myRecipient.Resolved Then
MsgBox "unknown recipient"
Else
newMail.Recipients.Add(myRecipient)
newMail.Send
End If
ol = Nil
exception err as oleexception
msgbox err.message
Open outlook Mail Item:
Dim myOlApp As OLEObject
Dim myItem As OLEObject
Dim olMailItem As OLEObject
myOlApp = New OLEObject("Outlook.Application")
myItem = myOlApp.CreateItem(olMailItem)
myItem.Display