![]() |
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
|
|||
|
|||
![]()
Hello
I really hope there is someone who could help with this slight problem. I use the following macro and it keeps breaking on me; Sub CopyEmailMsg() Dim myApp As Application Dim myNS As NameSpace Dim myFolder As Object Dim myItems As Outlook.MailItem 'Dim oAttachments As Outlook.Attachments Set myApp = New Outlook.Application Set myNS = myApp.GetNamespace("MAPI") Set myFolder = myNS.GetDefaultFolder(olFolderInbox).Folders("Clie nt").Folders("Subclient") 'Set myItems = myFolder.Items Set myDestFolder = myFolder.Folders("Subclient1") For Count = 1 To myFolder.Items.Count Set myMail = myFolder.Items(Count) myMail.SaveAs "C:\emails\" & StripChars(myMail.Subject) & ".msg", olMSG myMail.Move myDestFolder Next Count MsgBox "The emails have been copied and saved" End Sub Public Function StripChars(ByVal sStr) As String sStr = Replace(sStr, """", "") sStr = Replace(sStr, "'", "") sStr = Replace(sStr, ":", "") sStr = Replace(sStr, "/", "-") sStr = Replace(sStr, "\", "-") sStr = Replace(sStr, "?", "") StripChars = sStr End Function It works on a good number of emails in the folder however it then gives me the following error at times. I do not know why; The error is Run time error '-2147352567 (80020009) Array index out of bounds Please someone help; Many thanks Andrea |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook Macro | [email protected] | Outlook and VBA | 1 | February 28th 07 11:58 PM |
Outlook macro abends but Word macro runs successfully | Jreue | Outlook and VBA | 0 | December 14th 06 12:55 AM |
Call macro stored in Excel workbook from Outlook's macro | Gvaram | Outlook and VBA | 5 | October 4th 06 07:26 AM |
Can I mail to 250 without breaking it into three separate mailing | kohen | Outlook - Using Contacts | 1 | September 3rd 06 02:08 PM |
Breaking out to an external anchor | Scott Armitage | Outlook - General Queries | 0 | May 18th 06 09:27 PM |