Retrieving emails from a special outlook folder

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Retrieving emails from a special outlook folder

Post by Joerg Hamacher »

Hi again,

a customer wants us to retrieve emails that are in a special outlook folder.
Background is:
  • We have a large database with more than 10000 email addresses on IBMi
    Now we will automatically send an email to all those to ask them if they are interested in advertisment
    If not they shall send the mail back to a special mail address and all these mails will be posted in an "unsubscribe" folder in Outlook
    And then we have to retrieve these messages and the sender addresses and mark their email addresses in the IBMi database correspondingly.
I succeeded in getting access to this "unsubscribe" folder, I can even retrieve how many (unread) mails are stored there. But I do not get any informations to the mails inside. I use active-x components (MS Outlook MAPI) for getting so far and tried to compare my programmings with VBA tricks I found on several web sites (although I never programmed with VBA).
But at the end they define objects as type "object" which is not possible in LANSA VL in order to save the informations that are related with all the seperate mails. These mail informations seem to have a special defined fields structure and the "object" type fields receive this structure automatically by getting allocated to the MAPI component.

The following is a simple VBA code to retrieve 1 single mail in a default folder - can you help me to reproduce this with VL? I get this working in VL up to the statement next to last where "myItem" is used - and this is defined as type "object".

Code: Select all

Sub GetItem() 
 Dim myNameSpace As Outlook.NameSpace 
 Dim myFolder As Outlook.Folder 
 Dim myItem As Object 
 
 Set myNameSpace = Application.GetNameSpace("MAPI") 
 Set myFolder =  myNameSpace.GetDefaultFolder(olFolderInbox) 
 Set myItem = myFolder.Items(1) 
 myItem.Display 
End sub
Many thanks in advance,
Joerg
Post Reply