Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Save Email in MSG format (http://www.outlookbanter.com/outlook-vba/17254-save-email-msg-format.html)

LDMueller June 8th 06 04:43 PM

Save Email in MSG format
 
I have Outlook 2003. I want to be able to write a macro to do a File, Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!

Geoff June 8th 06 10:08 PM

Save Email in MSG format
 
I'm using Outlook 2002, but the following advice will probably work for
Outlook 2003. (You'll have to check.)

Have you tried the SaveAs method of the mail item object?
The SaveAs method takes the optional "Type" argument. You can specify the
type as "olMsg".

Here's an example.

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objSUBFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFLDR = objNS.Folders("Personal Folders")
Set objSUBFLDR = objFLDR.Folders("Inbox")
If objSUBFLDR.Items.Count 0 Then
Set objMI = objSUBFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objSUBFLDR = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

The problem with the above code is that Outlook security will prompt you
when the macro runs, saying that a program is trying to access Outlook data.
You will have to respond manually saying Yes (that's OK) or No. If this
intervention by security is a problem for you, then you would need to write
code using the Redemption library (if that's still usable in Outlook 2003).

Geoff





"LDMueller" wrote in message
...
I have Outlook 2003. I want to be able to write a macro to do a File, Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a
particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!




Michael Bauer June 9th 06 06:44 AM

Save Email in MSG format
 
Am Thu, 8 Jun 2006 21:08:18 +0100 schrieb Geoff:

Yes, the Redemption is also very usable in OL 2003 for a lot if things.

In OL 2003 you can avoid security prompts simply by using the instrinsic
Application object.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I'm using Outlook 2002, but the following advice will probably work for
Outlook 2003. (You'll have to check.)

Have you tried the SaveAs method of the mail item object?
The SaveAs method takes the optional "Type" argument. You can specify the
type as "olMsg".

Here's an example.

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objSUBFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFLDR = objNS.Folders("Personal Folders")
Set objSUBFLDR = objFLDR.Folders("Inbox")
If objSUBFLDR.Items.Count 0 Then
Set objMI = objSUBFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objSUBFLDR = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

The problem with the above code is that Outlook security will prompt you
when the macro runs, saying that a program is trying to access Outlook

data.
You will have to respond manually saying Yes (that's OK) or No. If this
intervention by security is a problem for you, then you would need to

write
code using the Redemption library (if that's still usable in Outlook

2003).

Geoff





"LDMueller" wrote in message
...
I have Outlook 2003. I want to be able to write a macro to do a File,

Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a
particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!


Geoff June 9th 06 09:03 AM

Save Email in MSG format
 
Michael,
Thanks for the tip.
Geoff

"Michael Bauer" wrote in message
...
Am Thu, 8 Jun 2006 21:08:18 +0100 schrieb Geoff:

Yes, the Redemption is also very usable in OL 2003 for a lot if things.

In OL 2003 you can avoid security prompts simply by using the instrinsic
Application object.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I'm using Outlook 2002, but the following advice will probably work for
Outlook 2003. (You'll have to check.)

Have you tried the SaveAs method of the mail item object?
The SaveAs method takes the optional "Type" argument. You can specify
the
type as "olMsg".

Here's an example.

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objSUBFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFLDR = objNS.Folders("Personal Folders")
Set objSUBFLDR = objFLDR.Folders("Inbox")
If objSUBFLDR.Items.Count 0 Then
Set objMI = objSUBFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objSUBFLDR = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

The problem with the above code is that Outlook security will prompt you
when the macro runs, saying that a program is trying to access Outlook

data.
You will have to respond manually saying Yes (that's OK) or No. If this
intervention by security is a problem for you, then you would need to

write
code using the Redemption library (if that's still usable in Outlook

2003).

Geoff





"LDMueller" wrote in message
...
I have Outlook 2003. I want to be able to write a macro to do a File,

Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a
particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!




LDMueller June 12th 06 05:08 PM

Save Email in MSG format
 
Thank you for your response. I really appreciate it.

I'm new at this and get the run-time error "The operation failed. An object
could not be found" on line Set objFLDR = objNS.Folders("Personal Folders")

I don't know enough to correct this.

Do you know why I'm getting it?

Thanks,
Leigh
"Geoff" wrote:

I'm using Outlook 2002, but the following advice will probably work for
Outlook 2003. (You'll have to check.)

Have you tried the SaveAs method of the mail item object?
The SaveAs method takes the optional "Type" argument. You can specify the
type as "olMsg".

Here's an example.

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objSUBFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFLDR = objNS.Folders("Personal Folders")
Set objSUBFLDR = objFLDR.Folders("Inbox")
If objSUBFLDR.Items.Count 0 Then
Set objMI = objSUBFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objSUBFLDR = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

The problem with the above code is that Outlook security will prompt you
when the macro runs, saying that a program is trying to access Outlook data.
You will have to respond manually saying Yes (that's OK) or No. If this
intervention by security is a problem for you, then you would need to write
code using the Redemption library (if that's still usable in Outlook 2003).

Geoff





"LDMueller" wrote in message
...
I have Outlook 2003. I want to be able to write a macro to do a File, Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a
particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!





Michael Bauer June 13th 06 07:35 AM

Save Email in MSG format
 
Am Mon, 12 Jun 2006 08:08:02 -0700 schrieb LDMueller:

That means, there´s no Folder in Outlook called "Personal Folders". If you
run a German version e.g. that folder is called "Persönliche Ordner".

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Thank you for your response. I really appreciate it.

I'm new at this and get the run-time error "The operation failed. An

object
could not be found" on line Set objFLDR = objNS.Folders("Personal

Folders")

I don't know enough to correct this.

Do you know why I'm getting it?

Thanks,
Leigh
"Geoff" wrote:

I'm using Outlook 2002, but the following advice will probably work for
Outlook 2003. (You'll have to check.)

Have you tried the SaveAs method of the mail item object?
The SaveAs method takes the optional "Type" argument. You can specify

the
type as "olMsg".

Here's an example.

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objSUBFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFLDR = objNS.Folders("Personal Folders")
Set objSUBFLDR = objFLDR.Folders("Inbox")
If objSUBFLDR.Items.Count 0 Then
Set objMI = objSUBFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objSUBFLDR = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

The problem with the above code is that Outlook security will prompt you
when the macro runs, saying that a program is trying to access Outlook

data.
You will have to respond manually saying Yes (that's OK) or No. If this
intervention by security is a problem for you, then you would need to

write
code using the Redemption library (if that's still usable in Outlook

2003).

Geoff





"LDMueller" wrote in message
...
I have Outlook 2003. I want to be able to write a macro to do a File,

Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a
particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!





Geoff June 13th 06 11:21 AM

Save Email in MSG format
 
Here's a revised example:

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem
Dim objATCH As Outlook.Attachment

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
' You need to point to the folder you want
' to save messages from on the next line:
Set objFLDR = objNS.GetDefaultFolder(olFolderInbox)
If objFLDR.Items.Count 0 Then
Set objMI = objFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

Geoff



"LDMueller" wrote in message
...
Thank you for your response. I really appreciate it.

I'm new at this and get the run-time error "The operation failed. An
object
could not be found" on line Set objFLDR = objNS.Folders("Personal
Folders")

I don't know enough to correct this.

Do you know why I'm getting it?

Thanks,
Leigh
"Geoff" wrote:

I'm using Outlook 2002, but the following advice will probably work for
Outlook 2003. (You'll have to check.)

Have you tried the SaveAs method of the mail item object?
The SaveAs method takes the optional "Type" argument. You can specify
the
type as "olMsg".

Here's an example.

Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFLDR As Outlook.MAPIFolder
Dim objSUBFLDR As Outlook.MAPIFolder
Dim objMI As Outlook.MailItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFLDR = objNS.Folders("Personal Folders")
Set objSUBFLDR = objFLDR.Folders("Inbox")
If objSUBFLDR.Items.Count 0 Then
Set objMI = objSUBFLDR.Items(1)
objMI.SaveAs "C:\Temp.msg", olMSG
End If

Set objMI = Nothing
Set objSUBFLDR = Nothing
Set objFLDR = Nothing
Set objNS = Nothing
Set objOL = Nothing

The problem with the above code is that Outlook security will prompt you
when the macro runs, saying that a program is trying to access Outlook
data.
You will have to respond manually saying Yes (that's OK) or No. If this
intervention by security is a problem for you, then you would need to
write
code using the Redemption library (if that's still usable in Outlook
2003).

Geoff





"LDMueller" wrote in message
...
I have Outlook 2003. I want to be able to write a macro to do a File,
Save
As, then save the email in Outlook Message Format (e.g. .MSG) to a
particular
location (e.g. W:\EMAIL\).

Can anyone help me?

Thanks!








All times are GMT +1. The time now is 10:17 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com