![]() |
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
|
|||
|
|||
![]()
I use Outlook 2002 and have written a macro to save e-mails on a
location on the hard drive. It works (mostly), but when I try to run it on a larger group of files, it doesn't save all of the files. We take care of same-name e-mails as a business process, so that does not explain the emails that won't save. (I am trying to automate the same-name e-mail problem as well, but that's a seperate issue.) Here is the code: On Error Resume Next Randomize iMsgCnt = 0 For Each sMsg In cf.Items If sMsg.GetInspector.EditorType = olEditorWord Then sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".RTF", olRTF ElseIf sMsg.GetInspector.EditorType = olEditorText Then sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".txt", olTXT ElseIf sMsg.GetInspector.EditorType = olEditorRTF Then sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".RTF", olRTF Else: sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".HTML", olHTML End If What am I missing? |
Ads |
#2
|
|||
|
|||
![]() As the loop isn't complete, do you move the message after it's saved? If so, loop backwards through the list. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Thu, 26 Jul 2007 17:26:49 -0000 schrieb NakedJ: I use Outlook 2002 and have written a macro to save e-mails on a location on the hard drive. It works (mostly), but when I try to run it on a larger group of files, it doesn't save all of the files. We take care of same-name e-mails as a business process, so that does not explain the emails that won't save. (I am trying to automate the same-name e-mail problem as well, but that's a seperate issue.) Here is the code: On Error Resume Next Randomize iMsgCnt = 0 For Each sMsg In cf.Items If sMsg.GetInspector.EditorType = olEditorWord Then sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".RTF", olRTF ElseIf sMsg.GetInspector.EditorType = olEditorText Then sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".txt", olTXT ElseIf sMsg.GetInspector.EditorType = olEditorRTF Then sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".RTF", olRTF Else: sMsg.SaveAs MyOrt & StripChars(sMsg.Subject) & ".HTML", olHTML End If What am I missing? |
#3
|
|||
|
|||
![]()
On Jul 27, 1:28 am, "Michael Bauer [MVP - Outlook]"
wrote: As the loop isn't complete, do you move the message after it's saved? If so, loop backwards through the list. I didn't post the whole thing. What I left out was: iMsgCnt = iMsgCnt + 1 Next I believe that this "closes the loop". The messages do not get moved/removed automatically. Should I still loop backwards? How do I do that?. Thanks for the response, I will research more on looping backwards. |
#4
|
|||
|
|||
![]()
On Jul 27, 8:24 am, NakedJ wrote:
On Jul 27, 1:28 am, "Michael Bauer [MVP - Outlook]" wrote: As the loop isn't complete, do you move the message after it's saved? If so, loop backwards through the list. I didn't post the whole thing. What I left out was: iMsgCnt = iMsgCnt + 1 Next I believe that this "closes the loop". The messages do not get moved/removed automatically. Should I still loop backwards? How do I do that?. Thanks for the response, I will research more on looping backwards. Did some testing this morning, it appears that file size has something to do with it. For example, if I strip attachments, I get 236 out of 246 emails saved, compared to 29 of 246. (Using the same emails otherwise. Still not getting all of them though. Any other ideas? The files that are being missed are not linear, that is, they are not necessarily the last ten that are missing. Jason |
#5
|
|||
|
|||
![]() What happens if you delete the On Error Resume Next line? This is a backwards loop: For i=Items.count To 1 step -1 .... next But it's only necessary if you move or delete items from the collection. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Fri, 27 Jul 2007 15:21:06 -0000 schrieb NakedJ: On Jul 27, 8:24 am, NakedJ wrote: On Jul 27, 1:28 am, "Michael Bauer [MVP - Outlook]" wrote: As the loop isn't complete, do you move the message after it's saved? If so, loop backwards through the list. I didn't post the whole thing. What I left out was: iMsgCnt = iMsgCnt + 1 Next I believe that this "closes the loop". The messages do not get moved/removed automatically. Should I still loop backwards? How do I do that?. Thanks for the response, I will research more on looping backwards. Did some testing this morning, it appears that file size has something to do with it. For example, if I strip attachments, I get 236 out of 246 emails saved, compared to 29 of 246. (Using the same emails otherwise. Still not getting all of them though. Any other ideas? The files that are being missed are not linear, that is, they are not necessarily the last ten that are missing. Jason |
#6
|
|||
|
|||
![]()
On Jul 30, 1:50 am, "Michael Bauer [MVP - Outlook]"
wrote: What happens if you delete the On Error Resume Next line? Nothing. I have found out the problem. There were inherent problems in the code that caused my HTML files not to save the body of the email, as well as an incomplete "stripchars" code. I was running into problems with emails that had a "/" or "\" in them. this problem was easily solved. I changed the code to look for bodyformat property instead of editor property, and to include the created date/time to prevent same subject e-mail problem. Now I can save all e-mails to files. Last feature I would like to add is a count function that will show "Saved X out of Y e-mails." Any ideas to get me started? This is not a deal breaker. Thanks for your help. Jason |
#7
|
|||
|
|||
![]() After one message is saved increase iMsgCnt by 1. The total is cf.Items.Count. you can display a message with the MsgBox function. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Mon, 30 Jul 2007 13:42:32 -0000 schrieb NakedJ: On Jul 30, 1:50 am, "Michael Bauer [MVP - Outlook]" wrote: What happens if you delete the On Error Resume Next line? Nothing. I have found out the problem. There were inherent problems in the code that caused my HTML files not to save the body of the email, as well as an incomplete "stripchars" code. I was running into problems with emails that had a "/" or "\" in them. this problem was easily solved. I changed the code to look for bodyformat property instead of editor property, and to include the created date/time to prevent same subject e-mail problem. Now I can save all e-mails to files. Last feature I would like to add is a count function that will show "Saved X out of Y e-mails." Any ideas to get me started? This is not a deal breaker. Thanks for your help. Jason |
#8
|
|||
|
|||
![]()
On Jul 31, 1:47 am, "Michael Bauer [MVP - Outlook]"
wrote: After one message is saved increase iMsgCnt by 1. The total is cf.Items.Count. you can display a message with the MsgBox function. Thanks for all of the help. Instead, I added an error log function so that I can identify problem files. I may still add the count function though, it seems like ti would be pretty straight forward. Cheers |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trouble downloading mail from ISP | John Keith | Outlook - General Queries | 2 | December 11th 06 03:48 AM |
trouble in sending e-mail | wetompkins | Outlook Express | 9 | September 21st 06 11:57 AM |
Save email as text file macro | Simon | Outlook and VBA | 7 | August 10th 06 04:10 PM |
Save Attachment Using Macro | [email protected] | Outlook and VBA | 3 | August 8th 06 03:42 PM |
macro trouble | windandwaves | Outlook and VBA | 4 | March 21st 06 08:08 PM |