[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1596
  • Last Modified:

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.  http://www.dimastr.com/redemption/.
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?
MY CODE:
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.
sItem.Save
End Sub
 
SAMPLE CODE ON THE REDEMPTION SITE:
 
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
Msg.Save
'Only their sample code, and no variations, seem to work.

Open in new window

0
emkarol
Asked:
emkarol
  • 2
1 Solution
 
oleggoldCommented:
0
 
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
    msg.Save
    Set mySession = Nothing
End Sub

Open in new window

0
 
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.)
0
 
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 michael.karol@sent.com.  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.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now