Cannot Import .MSG Files as Mail Items into .PST File Using Redemption

Using Outlook 2003 on Windows XP, and Redemption.  I'm having a lot of trouble using VBA to import .msg files (regular e-mails) back into a .pst file.  I'm a beginner and I guess I don't understand the Redemption syntax well.  The sample code on the Redemption site says that "'olMSG, olRFC822 and olTNEF formats are supported."  See this link.
The code works, but the items show up in the inbox as some sort of post item rather than an actual regular mail item.  I know it has something to do with the number after "Items.Add" but type (0) (supposed to be regular e-mail) does not work (i.e., nothing happens when the code is run).  Any way to make this work so that the items show up after the import as regular e-mails?
Sub ImportMSGFile(x)
Dim sItem, oItem
Set sItem = CreateObject("Redemption.SafeMailItem")
Set oItem = Application.Session.GetDefaultFolder(6).Items.Add(6) 'I don't know what (6) corresponds to, but it's apparently some type of weird post item.  Would love to change to regular mail. 
sItem.Item = oItem
sItem.Import "E:\MyFiles\Admin\HoldFile\TobeImported\" & x, 3 'I know the 3 is critical, but I can't figure out what to change it to.
End Sub
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Msg = Session.GetDefaultFolder(16).Items.Add(6)
Msg.Import "c:\temp\test.msg", 3  'olMSG, olRFC822 and olTNEF formats are supported
'Only their sample code, and no variations, seem to work.

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi, emkarol.

Try this version.  Call it like this:

    ImportMsgFile SomeFileName.msg
Sub ImportMsgFile(strFile As String)
    Dim mySession As Redemption.RDOSession
    Set mySession = CreateObject("Redemption.RDOSession")
    mySession.MAPIOBJECT = Application.Session.MAPIOBJECT
    Set msg = mySession.GetDefaultFolder(6).Items.Add(6)
    msg.Import "E:\MyFiles\Admin\HoldFile\TobeImported\" & strFile, 3  'olMSG, olRFC822 and olTNEF formats are supported
    Set mySession = Nothing
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
emkarolAuthor Commented:
Excellent!!!!!  BlueDevilFan's solution would appear to work.  Not sure why, but it does.  You have to re-DIM the variable after you use it in a new sub, I guess.  Told you I was a beginner.  (I'll have to do further testing later when time permits, but this is great.)
emkarolAuthor Commented:
Thanks very much!  As I said, not really sure why it works (probably re-DIMming the variable), but it seems to.  You seem to know what you are doing.  I wonder whether you have time to do some programming work.  If you do, e-mail me at  I'm an individual and not an enterprise, thus, I can't pay a huge amount of money.  But, I'm trying to develop some stuff that helps with my work.  The only problem is that I should be working, not programming!  Whatever the case, thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.