A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro button that saves the email I'm reading to c:\outlook as .ms



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 25th 06, 07:39 PM posted to microsoft.public.outlook.program_vba
kvpb2000
external usenet poster
 
Posts: 3
Default Macro button that saves the email I'm reading to c:\outlook as .ms

Hi,

I want to:
1) open an email that's in my inbox
2) read the email
3) decide that I'd like to copy this email to a c:\outlook folder in Windows
Explorer
4) click on the assigned macro button at the top of the email I'm reading
and save the email that's open to c:\outlook folder in an .msg file format.

I've found code that's done this but the code I tried saves the last email
in my list of emails of my inbox and not the one that I have open. Does
anyone know how to specifically open an email so it takes up your entire
screen, read it, and then have a macro button in the same email save to a
c:\outlook folder. Here is the code that I found from someplace else that's
close, but again, it grabs the last email of my list and not the email that's
open. ( I understand that it's pulling the last email because of the
statement (Items(1)) , I just need to know how to get around that and to save
the email that's open )

Sub saveemail()

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:\outlook\Temp.msg", olMSG
End If


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


End Sub






Ads
  #2  
Old October 25th 06, 08:04 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Macro button that saves the email I'm reading to c:\outlook as .ms

If you are reading a message in an inspector, use
Application.ActiveInspector.CurrentItem.SaveAs.
If you are reading in the preview pane, use
Application.ActiveExplorer.Selection.Item(1).SaveA s.
All error checking is omitted above of course.

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

"kvpb2000" wrote in message
...
Hi,

I want to:
1) open an email that's in my inbox
2) read the email
3) decide that I'd like to copy this email to a c:\outlook folder in
Windows
Explorer
4) click on the assigned macro button at the top of the email I'm reading
and save the email that's open to c:\outlook folder in an .msg file
format.

I've found code that's done this but the code I tried saves the last email
in my list of emails of my inbox and not the one that I have open. Does
anyone know how to specifically open an email so it takes up your entire
screen, read it, and then have a macro button in the same email save to a
c:\outlook folder. Here is the code that I found from someplace else
that's
close, but again, it grabs the last email of my list and not the email
that's
open. ( I understand that it's pulling the last email because of the
statement (Items(1)) , I just need to know how to get around that and to
save
the email that's open )

Sub saveemail()

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:\outlook\Temp.msg", olMSG
End If


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


End Sub








  #3  
Old October 25th 06, 08:21 PM posted to microsoft.public.outlook.program_vba
kvpb2000
external usenet poster
 
Posts: 3
Default Macro button that saves the email I'm reading to c:\outlook as

Hi Dmitry,

Thanks for the code but where in my existing code does the two lines you
mentioned fit? I tried it in the middle and the code turned red.

Application.ActiveInspector.CurrentItem.SaveAs.
Application.ActiveExplorer.Selection.Item(1).SaveA s.

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)

Application.ActiveInspector.CurrentItem.SaveAs.


If objFLDR.Items.Count 0 Then
Set objMI = objFLDR.Items(1)
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If

"Dmitry Streblechenko" wrote:

If you are reading a message in an inspector, use
Application.ActiveInspector.CurrentItem.SaveAs.
If you are reading in the preview pane, use
Application.ActiveExplorer.Selection.Item(1).SaveA s.
All error checking is omitted above of course.

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

"kvpb2000" wrote in message
...
Hi,

I want to:
1) open an email that's in my inbox
2) read the email
3) decide that I'd like to copy this email to a c:\outlook folder in
Windows
Explorer
4) click on the assigned macro button at the top of the email I'm reading
and save the email that's open to c:\outlook folder in an .msg file
format.

I've found code that's done this but the code I tried saves the last email
in my list of emails of my inbox and not the one that I have open. Does
anyone know how to specifically open an email so it takes up your entire
screen, read it, and then have a macro button in the same email save to a
c:\outlook folder. Here is the code that I found from someplace else
that's
close, but again, it grabs the last email of my list and not the email
that's
open. ( I understand that it's pulling the last email because of the
statement (Items(1)) , I just need to know how to get around that and to
save
the email that's open )

Sub saveemail()

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:\outlook\Temp.msg", olMSG
End If


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


End Sub









  #4  
Old October 25th 06, 08:42 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Macro button that saves the email I'm reading to c:\outlook as

Set objOL = New Outlook.Application
objOL.ActiveInspector.CurrentItem.SaveAs "c:\test.msg", 3

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

"kvpb2000" wrote in message
...
Hi Dmitry,

Thanks for the code but where in my existing code does the two lines you
mentioned fit? I tried it in the middle and the code turned red.

Application.ActiveInspector.CurrentItem.SaveAs.
Application.ActiveExplorer.Selection.Item(1).SaveA s.

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)

Application.ActiveInspector.CurrentItem.SaveAs.


If objFLDR.Items.Count 0 Then
Set objMI = objFLDR.Items(1)
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If

"Dmitry Streblechenko" wrote:

If you are reading a message in an inspector, use
Application.ActiveInspector.CurrentItem.SaveAs.
If you are reading in the preview pane, use
Application.ActiveExplorer.Selection.Item(1).SaveA s.
All error checking is omitted above of course.

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

"kvpb2000" wrote in message
...
Hi,

I want to:
1) open an email that's in my inbox
2) read the email
3) decide that I'd like to copy this email to a c:\outlook folder in
Windows
Explorer
4) click on the assigned macro button at the top of the email I'm
reading
and save the email that's open to c:\outlook folder in an .msg file
format.

I've found code that's done this but the code I tried saves the last
email
in my list of emails of my inbox and not the one that I have open.
Does
anyone know how to specifically open an email so it takes up your
entire
screen, read it, and then have a macro button in the same email save to
a
c:\outlook folder. Here is the code that I found from someplace else
that's
close, but again, it grabs the last email of my list and not the email
that's
open. ( I understand that it's pulling the last email because of the
statement (Items(1)) , I just need to know how to get around that and
to
save
the email that's open )

Sub saveemail()

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:\outlook\Temp.msg", olMSG
End If


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


End Sub











  #5  
Old October 26th 06, 12:48 AM posted to microsoft.public.outlook.program_vba
kvpb2000
external usenet poster
 
Posts: 3
Default Macro button that saves the email I'm reading to c:\outlook as

Thank you very much Dmitry, that worked GREAT!!!

I'm sure other people who read this blog will find that your suggestion
works excellent. Here's the finished product:

Sub saveemail()

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.Application.ActiveInspector.CurrentI tem
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If


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


End Sub

"Dmitry Streblechenko" wrote:

Set objOL = New Outlook.Application
objOL.ActiveInspector.CurrentItem.SaveAs "c:\test.msg", 3

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

"kvpb2000" wrote in message
...
Hi Dmitry,

Thanks for the code but where in my existing code does the two lines you
mentioned fit? I tried it in the middle and the code turned red.

Application.ActiveInspector.CurrentItem.SaveAs.
Application.ActiveExplorer.Selection.Item(1).SaveA s.

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)

Application.ActiveInspector.CurrentItem.SaveAs.


If objFLDR.Items.Count 0 Then
Set objMI = objFLDR.Items(1)
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If

"Dmitry Streblechenko" wrote:

If you are reading a message in an inspector, use
Application.ActiveInspector.CurrentItem.SaveAs.
If you are reading in the preview pane, use
Application.ActiveExplorer.Selection.Item(1).SaveA s.
All error checking is omitted above of course.

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

"kvpb2000" wrote in message
...
Hi,

I want to:
1) open an email that's in my inbox
2) read the email
3) decide that I'd like to copy this email to a c:\outlook folder in
Windows
Explorer
4) click on the assigned macro button at the top of the email I'm
reading
and save the email that's open to c:\outlook folder in an .msg file
format.

I've found code that's done this but the code I tried saves the last
email
in my list of emails of my inbox and not the one that I have open.
Does
anyone know how to specifically open an email so it takes up your
entire
screen, read it, and then have a macro button in the same email save to
a
c:\outlook folder. Here is the code that I found from someplace else
that's
close, but again, it grabs the last email of my list and not the email
that's
open. ( I understand that it's pulling the last email because of the
statement (Items(1)) , I just need to know how to get around that and
to
save
the email that's open )

Sub saveemail()

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:\outlook\Temp.msg", olMSG
End If


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


End Sub












  #6  
Old October 26th 06, 01:18 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Macro button that saves the email I'm reading to c:\outlook as

There is absolutely no reason to retrive the Inbox folder. You also need to
perform at least some sanity checks. I am alsdso not sure why you'dd ever
want to write
objFLDR.Items.Application
instead of
objOL

Dim objOL As Outlook.Application
Dim objMI As Outlook.MailItem
Dim objATCH As Outlook.Attachment

Set objOL = New Outlook.Application

If not (objOL.ActiveInspector Is Nothing) Then
Set objMI = objOL.ActiveInspector.CurrentItem
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If


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


End Sub


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

"kvpb2000" wrote in message
...
Thank you very much Dmitry, that worked GREAT!!!

I'm sure other people who read this blog will find that your suggestion
works excellent. Here's the finished product:

Sub saveemail()

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.Application.ActiveInspector.CurrentI tem
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If


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


End Sub

"Dmitry Streblechenko" wrote:

Set objOL = New Outlook.Application
objOL.ActiveInspector.CurrentItem.SaveAs "c:\test.msg", 3

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

"kvpb2000" wrote in message
...
Hi Dmitry,

Thanks for the code but where in my existing code does the two lines
you
mentioned fit? I tried it in the middle and the code turned red.

Application.ActiveInspector.CurrentItem.SaveAs.
Application.ActiveExplorer.Selection.Item(1).SaveA s.

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)

Application.ActiveInspector.CurrentItem.SaveAs.


If objFLDR.Items.Count 0 Then
Set objMI = objFLDR.Items(1)
objMI.SaveAs "C:\outlook\Temp.msg", olMSG
End If

"Dmitry Streblechenko" wrote:

If you are reading a message in an inspector, use
Application.ActiveInspector.CurrentItem.SaveAs.
If you are reading in the preview pane, use
Application.ActiveExplorer.Selection.Item(1).SaveA s.
All error checking is omitted above of course.

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

"kvpb2000" wrote in message
...
Hi,

I want to:
1) open an email that's in my inbox
2) read the email
3) decide that I'd like to copy this email to a c:\outlook folder in
Windows
Explorer
4) click on the assigned macro button at the top of the email I'm
reading
and save the email that's open to c:\outlook folder in an .msg file
format.

I've found code that's done this but the code I tried saves the last
email
in my list of emails of my inbox and not the one that I have open.
Does
anyone know how to specifically open an email so it takes up your
entire
screen, read it, and then have a macro button in the same email save
to
a
c:\outlook folder. Here is the code that I found from someplace
else
that's
close, but again, it grabs the last email of my list and not the
email
that's
open. ( I understand that it's pulling the last email because of the
statement (Items(1)) , I just need to know how to get around that
and
to
save
the email that's open )

Sub saveemail()

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:\outlook\Temp.msg", olMSG
End If


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


End Sub














  #7  
Old November 2nd 06, 10:47 AM posted to microsoft.public.outlook.program_vba
armando cazzetta
external usenet poster
 
Posts: 5
Default Macro button that saves the email I'm reading to c:\outlook as

can you tell me, step by step, what i do did to run this macro?
when i try : error 91

*** Sent via Developersdex http://www.developersdex.com ***
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Button To Form That Automatically Saves Contents To Text File Dani Outlook - Using Forms 1 September 19th 06 02:17 PM
OL2k7: Macro to flag & categorize message from reading pane Michael D. Adams Outlook and VBA 2 June 10th 06 07:24 PM
Run Macro when user saves Flemming Outlook - Using Forms 7 May 16th 06 02:55 PM
Outlook 2000 - Button to run Macro then open Database David C Outlook and VBA 1 January 25th 06 04:44 PM
macro to toggle reading in plain text Mark Outlook and VBA 1 January 16th 06 09:32 AM


All times are GMT +1. The time now is 04:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.