0

i'm trying to create a program that conver eml file into a single pst. i have write that command:

RDOSession session = new RDOSession();
RDOPstStore store = session.LogonPstStore(newpstpath);
RDOFolder folder = store.IPMRootFolder.Folders.Item(directoryEmlFile);
RDOMail mail = folder.Items.Add("IPM.Note");

but at the command "RDOMail mail = folder.Items.Add("IPM.Note")" the system give me the null exception. can anyone help me?

2 Answers2

1

You need to differ Outlook and Redemption objects.

It looks like you need to use the GetRDOObjectFromOutlookObject method of the Session class (Redemption).

 set Session = CreateObject("Redemption.RDOSession")
 Session.MAPIOBJECT = Application.Session.MAPIOBJECT
 set redItem= Session.GetRDOObjectFromOutlookObject(mail)

The Add method of the Items class creates and returns a new Outlook item in the Items collection for the folder.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
0

Most likely the folder variable is null - if the folder does not exist, retrieving it by name (RDOFolder.Folders.Item("foldername")) will return null:

RDOSession session = new RDOSession();
RDOPstStore store = session.LogonPstStore(newpstpath);
RDOFolder folder = store.IPMRootFolder.Folders.Item(directoryEmlFile);
if (folder == null) folder = store.IPMRootFolder.Folders.Add(directoryEmlFile);
RDOMail mail = folder.Items.Add("IPM.Note");
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78