![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 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
|
|||
|
|||
![]()
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 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
|
|||
|
|||
![]()
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 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 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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |