RPC_E_SERVERFAULT error when trying to import mail

  • Thread starter François Miermont
  • Start date
F

François Miermont

Hi there,

I have a problem when trying to import .msg files to outlook : it throws an
error :
"The server threw an exception. (Exception from HRESULT: 0x80010105
(RPC_E_SERVERFAULT))" and make Outlook crash (encountered a problem and needs
to close...). This error doesn't happend on the same MSG File : sometimes, it
appends when it imports about 200 files, sometimes 80...

In fact, I've made a file miror of my Mailboxes : foreach folder in my
mailbox, i make a directory, foreach mail in a folder, I save it as a MSG
File in the directory. This works perfectly without any problem. Let's call
it the Export method.

Now, I try to make the Import method : foreach Directory, I make a folder in
my inbox, foreach MSG File in that directory I make a mail.

I do it recursively using this code :

ApplicationClass myOlApp = new ApplicationClass();
NameSpace newNS = myOlApp.GetNamespace("MAPI");
MAPIFolder mapi1 = newNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
PutMail(myOlApp, mapi1, @"C:\temp\outlook\Inbox");

And this is PutMail :
private void PutMail(ApplicationClass myOlApp, MAPIFolder baseFolder, string
restaurePath)
{
DirectoryInfo root = new DirectoryInfo(restaurePath);
foreach (FileInfo file in root.GetFiles())
{
if (file.Extension == ".msg")
{
MailItem item =
(MailItem)myOlApp.CreateItemFromTemplate(file.FullName, baseFolder);
item = (MailItem)item.Move(baseFolder);
item.Save();
}
}

foreach (DirectoryInfo directory in root.GetDirectories())
{
MAPIFolder myNewFolder = baseFolder.Folders.Add(directory.Name,
OlDefaultFolders.olFolderInbox);
PutMail(myOlApp, myNewFolder, directory.FullName);
System.Runtime.InteropServices.Marshal.ReleaseComObject(myNewFolder);
}
}

I use myOlApp.CreateItemFromTemplate because I didn't find another way to
import a MSG File (except using Redemption but I don't want to).

The error is always throw on this call :
MAPIFolder myNewFolder = baseFolder.Folders.Add(directory.Name,
OlDefaultFolders.olFolderInbox);

Any help will be welcome :)
 
F

François Miermont

I'm sorry I have forgotten some details :
-Office 2003 SP2
-Windows XP SP2
 
E

Eric Legault [MVP - Outlook]

The CreateItemFromTemplate method is ONLY to be used with .oft files, not
..msg files. I recommend you stick with Redemption.
 
S

Sue Mosher [MVP-Outlook]

Why do you say that, Eric? There are scenarios where CreateItemFromTemplate can be useful with a .msg file -- say if you want to get at the attachments in a message that was itself an attachment to another message.

What looks to me like a problem in François' code is that he's creating the message in a folder, then moving the message to that same folder then saving it. But of course there's nothing to save because the item was moved (and messages don't like to be created in folders; they're always in Drafts). I'd try using System.Missing as the 2nd parameter in CreateItemFromTemplate.

Also if he's adding a folder to an existing mail folder's Folders collection, he could try specifying System.Missing instead of OlDefaultFolders.olFolderInbox.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
E

Eric Legault [MVP - Outlook]

Ya lost me Sue! I thought you can only pass the path to an .oft file as the
argument to the CreateItemFromTemplate method?? Isn't he trying to import an
..msg file into a MAPIFolder? In that case, wouldn't the CopyFile method be
apprpriate? But doesn't that create a DocumentItem object from an .msg file,
not the Mailitem object you'd expect?

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
S

Sue Mosher [MVP-Outlook]

CreateItemFromTemplate *does* work with .msg files. It just doesn't necessarily do what people expect, because it does what the method describes -- creates a new item using the .msg file as a template. That means it's no good for importing messages.

The only import technique I know that works is Redemption's.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

François Miermont

Okay now it works perfectly using System.Reflexion.Missing.Value in
CreateItemFromTemplate and Folders.Add.

But now it works, I see that it did not do what I expect : the process
really restore my mails in correct folders, but these mails are not marked as
sent.
Exemple : I received a mail from thomas, my friend. I can open it, and then
choose Reply.
I export this mail, delete it in Outlook, and then restore it. Now, in this
mail I can read "This message has not been sent". If I open it, I haven't
access to the Reply button : instead of I only have Send.

Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
S

Sue Mosher [MVP-Outlook]

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

François Miermont

I dont have any idea of how using ExMapi with .net. If you have any links :)
 
S

Sue Mosher [MVP-Outlook]

Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Francois Miermont

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

Sue Mosher said:
Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



François Miermont said:
I dont have any idea of how using ExMapi with .net. If you have any links :)

Sue Mosher said:
The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
F

Francois Miermont

Okay I just try to use Redemption to see what I can do with it. So I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg file
without creating a new item in Outlook. The given code is like this :
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

Francois Miermont said:
Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

Sue Mosher said:
Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



François Miermont said:
I dont have any idea of how using ExMapi with .net. If you have any links :)

:

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
S

Sue Mosher [MVP-Outlook]

Take a look at the sample at http://www.outlookcode.com/codedetail.aspx?id=716, which has worked fine for me. You need to set the MessageClass to "IPM.Note" after you perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
Okay I just try to use Redemption to see what I can do with it. So I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg file
without creating a new item in Outlook. The given code is like this :
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

Francois Miermont said:
Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

Sue Mosher said:
Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/


"François Miermont" <fmiermont[at]netfinances.fr> wrote in message I dont have any idea of how using ExMapi with .net. If you have any links :)

:

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
F

Francois Miermont

It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

Sue Mosher said:
Take a look at the sample at http://www.outlookcode.com/codedetail.aspx?id=716, which has worked fine for me. You need to set the MessageClass to "IPM.Note" after you perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
Okay I just try to use Redemption to see what I can do with it. So I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg file
without creating a new item in Outlook. The given code is like this :
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

Francois Miermont said:
Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/


"François Miermont" <fmiermont[at]netfinances.fr> wrote in message I dont have any idea of how using ExMapi with .net. If you have any links :)

:

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
S

Sue Mosher [MVP-Outlook]

Redemption will pass the MessageClass through to the SafeMailItem.Item, but C# doesn't know that, and I don't do that language, so I don't know how you're supposed to code it. You could try SafeMailItem.Save, followed by setting SafeMailItem.Item.MessageClass and then SafeMailItem.Item.Save

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

Sue Mosher said:
Take a look at the sample at http://www.outlookcode.com/codedetail.aspx?id=716, which has worked fine for me. You need to set the MessageClass to "IPM.Note" after you perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
Okay I just try to use Redemption to see what I can do with it. So I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg file
without creating a new item in Outlook. The given code is like this :
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

:

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/


"François Miermont" <fmiermont[at]netfinances.fr> wrote in message I dont have any idea of how using ExMapi with .net. If you have any links :)

:

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
F

Francois Miermont

Just try it and does not work :/

Is there a way to ask Redemption's author directly ?

Sue Mosher said:
Redemption will pass the MessageClass through to the SafeMailItem.Item, but C# doesn't know that, and I don't do that language, so I don't know how you're supposed to code it. You could try SafeMailItem.Save, followed by setting SafeMailItem.Item.MessageClass and then SafeMailItem.Item.Save

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

Sue Mosher said:
Take a look at the sample at http://www.outlookcode.com/codedetail.aspx?id=716, which has worked fine for me. You need to set the MessageClass to "IPM.Note" after you perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Okay I just try to use Redemption to see what I can do with it. So I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg file
without creating a new item in Outlook. The given code is like this :
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

:

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/


"François Miermont" <fmiermont[at]netfinances.fr> wrote in message I dont have any idea of how using ExMapi with .net. If you have any links :)

:

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
F

Francois Miermont

Interresting, I've just tested to trace the content of MessageClass :
when the message is imported, MessageClass = "IPM.Note"
when it's saved, MessageClass = "IPM.Note"

Furthermore, when locking the documention about MailItem, MessageClass is a
get/set attribute ! So, I have tested setting MessageClass in my method using
CreateFromTemplate. The set seems to work, but unfortunately it does not
solve my problem, as it's already set as "IPM.Note"

Maybe MessageClass is not the solution ?

Francois Miermont said:
Just try it and does not work :/

Is there a way to ask Redemption's author directly ?

Sue Mosher said:
Redemption will pass the MessageClass through to the SafeMailItem.Item, but C# doesn't know that, and I don't do that language, so I don't know how you're supposed to code it. You could try SafeMailItem.Save, followed by setting SafeMailItem.Item.MessageClass and then SafeMailItem.Item.Save

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

:

Take a look at the sample at http://www.outlookcode.com/codedetail.aspx?id=716, which has worked fine for me. You need to set the MessageClass to "IPM.Note" after you perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Okay I just try to use Redemption to see what I can do with it. So I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg file
without creating a new item in Outlook. The given code is like this :
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

:

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a third-party wrapper there, too -- http://www.mapi33.adexsolutions.com/


"François Miermont" <fmiermont[at]netfinances.fr> wrote in message I dont have any idea of how using ExMapi with .net. If you have any links :)

:

The Outlook object model provides no way to do that programmatically. You have to go to either Extended MAPI or Redemption.

"François Miermont" <fmiermont[at]netfinances.fr> wrote in message
Sue you says that CreateItemFromTemplate is not the correct method to import
msg file, as it not import the mail, but create a new item from this mail.
But what can I do if I don't want to use Redemption ? In fact, I just want to
do the same behaviour as if I drag&drop a MSG file into Outlook.
 
D

Dmitry Streblechenko

Here I am :)
SafeMailItem object in Redemption only exposes properties and methods
blocked by the Outlook Object Model. MessageClass is not blocked, hence
SafeMailItem does not implement it. You can either set that property on the
original Outlook object assigned to the SafeMailItem.Item property or use
RDOMail object (no Outlook objects involed) -
http://www.dimastr.com/redemption/rdo/. RDOMail object has a Sent property,
which is, unlike OOM, r/w, but you will get an error if you set it after the
message was saved at least once (just a MAPI limitation). This way you don't
even need to mess with the MessageClass - just call Import(), then set the
Sent property ot true.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Francois Miermont said:
Just try it and does not work :/

Is there a way to ask Redemption's author directly ?

Sue Mosher said:
Redemption will pass the MessageClass through to the SafeMailItem.Item,
but C# doesn't know that, and I don't do that language, so I don't know
how you're supposed to code it. You could try SafeMailItem.Save, followed
by setting SafeMailItem.Item.MessageClass and then SafeMailItem.Item.Save

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Francois Miermont said:
It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

:

Take a look at the sample at
http://www.outlookcode.com/codedetail.aspx?id=716, which has worked
fine for me. You need to set the MessageClass to "IPM.Note" after you
perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



in message Okay I just try to use Redemption to see what I can do with it. So
I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg
file
without creating a new item in Outlook. The given code is like this
:
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF
formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the
imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

:

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect
using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a
third-party wrapper there, too --
http://www.mapi33.adexsolutions.com/


"Francois Miermont" <fmiermont[at]netfinances.fr> wrote in
message
I dont have any idea of how using ExMapi with .net. If you have
any links :)

:

The Outlook object model provides no way to do that
programmatically. You have to go to either Extended MAPI or
Redemption.

"Francois Miermont" <fmiermont[at]netfinances.fr> wrote in
message

Sue you says that CreateItemFromTemplate is not the correct
method to import
msg file, as it not import the mail, but create a new item
from this mail.
But what can I do if I don't want to use Redemption ? In
fact, I just want to
do the same behaviour as if I drag&drop a MSG file into
Outlook.
 
S

Sue Mosher [MVP-Outlook]

Sounds like I need to update my sample for Redemption 4.0, huh?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Dmitry Streblechenko said:
Here I am :)
SafeMailItem object in Redemption only exposes properties and methods
blocked by the Outlook Object Model. MessageClass is not blocked, hence
SafeMailItem does not implement it. You can either set that property on the
original Outlook object assigned to the SafeMailItem.Item property or use
RDOMail object (no Outlook objects involed) -
http://www.dimastr.com/redemption/rdo/. RDOMail object has a Sent property,
which is, unlike OOM, r/w, but you will get an error if you set it after the
message was saved at least once (just a MAPI limitation). This way you don't
even need to mess with the MessageClass - just call Import(), then set the
Sent property ot true.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Francois Miermont said:
Just try it and does not work :/

Is there a way to ask Redemption's author directly ?

Sue Mosher said:
Redemption will pass the MessageClass through to the SafeMailItem.Item,
but C# doesn't know that, and I don't do that language, so I don't know
how you're supposed to code it. You could try SafeMailItem.Save, followed
by setting SafeMailItem.Item.MessageClass and then SafeMailItem.Item.Save

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



message It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

:

Take a look at the sample at
http://www.outlookcode.com/codedetail.aspx?id=716, which has worked
fine for me. You need to set the MessageClass to "IPM.Note" after you
perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



in message Okay I just try to use Redemption to see what I can do with it. So
I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg
file
without creating a new item in Outlook. The given code is like this
:
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF
formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the
imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

:

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect
using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a
third-party wrapper there, too --
http://www.mapi33.adexsolutions.com/


"Francois Miermont" <fmiermont[at]netfinances.fr> wrote in
message
I dont have any idea of how using ExMapi with .net. If you have
any links :)

:

The Outlook object model provides no way to do that
programmatically. You have to go to either Extended MAPI or
Redemption.

"Francois Miermont" <fmiermont[at]netfinances.fr> wrote in
message

Sue you says that CreateItemFromTemplate is not the correct
method to import
msg file, as it not import the mail, but create a new item
from this mail.
But what can I do if I don't want to use Redemption ? In
fact, I just want to
do the same behaviour as if I drag&drop a MSG file into
Outlook.
 
F

Francois Miermont

Hello Dmitry :)

I have tested RDOMail object, and putting the Sent propertie to true, and I
works ! Furthermore, I have incredible performance, less than one minute to
restore a 150MB mailbox !

Just a little question : the unread flag seems to not be restored despite it
is really saved. What can I do to solve this minor problem ?

Dmitry Streblechenko said:
Here I am :)
SafeMailItem object in Redemption only exposes properties and methods
blocked by the Outlook Object Model. MessageClass is not blocked, hence
SafeMailItem does not implement it. You can either set that property on the
original Outlook object assigned to the SafeMailItem.Item property or use
RDOMail object (no Outlook objects involed) -
http://www.dimastr.com/redemption/rdo/. RDOMail object has a Sent property,
which is, unlike OOM, r/w, but you will get an error if you set it after the
message was saved at least once (just a MAPI limitation). This way you don't
even need to mess with the MessageClass - just call Import(), then set the
Sent property ot true.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Francois Miermont said:
Just try it and does not work :/

Is there a way to ask Redemption's author directly ?

Sue Mosher said:
Redemption will pass the MessageClass through to the SafeMailItem.Item,
but C# doesn't know that, and I don't do that language, so I don't know
how you're supposed to code it. You could try SafeMailItem.Save, followed
by setting SafeMailItem.Item.MessageClass and then SafeMailItem.Item.Save

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



message It seems that I don"t have this MessageClass propertie avaible in my
SafeMailItem Class ?

:

Take a look at the sample at
http://www.outlookcode.com/codedetail.aspx?id=716, which has worked
fine for me. You need to set the MessageClass to "IPM.Note" after you
perform the import.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



in message Okay I just try to use Redemption to see what I can do with it. So
I'll try
to import my msg file.

On the Redemption website, I'm unable to find a way to import a msg
file
without creating a new item in Outlook. The given code is like this
:
dim sItem, oItem
set sItem = CreateObject("Redemption.SafeMailItem")
set oItem = Application.Session.GetDefaultFolder(16).Items.Add(6)
sItem.Item = oItem
sItem.Import "c:\temp\test.msg", 3 'olMSG, olRFC822 and olTNEF
formats are
supported
sItem.Save

In fact, it the same behaviour as an ImportFromTemplate call : the
imported
mail is a new item, so I haven't the Reply button.

Or maybe I'm not doing it correctly ?

:

Sweet, this is a non-free wrapper that cost the same as Redemption.

So there is no way to import an msg file in outlook in .net expect
using
redemption ? I can't understand that !

:

Extended MAPI is not supported in .NET. You'd have to go to a
third-party wrapper there, too --
http://www.mapi33.adexsolutions.com/


"Francois Miermont" <fmiermont[at]netfinances.fr> wrote in
message
I dont have any idea of how using ExMapi with .net. If you have
any links :)

:

The Outlook object model provides no way to do that
programmatically. You have to go to either Extended MAPI or
Redemption.

"Francois Miermont" <fmiermont[at]netfinances.fr> wrote in
message

Sue you says that CreateItemFromTemplate is not the correct
method to import
msg file, as it not import the mail, but create a new item
from this mail.
But what can I do if I don't want to use Redemption ? In
fact, I just want to
do the same behaviour as if I drag&drop a MSG file into
Outlook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top