Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving outlook text files
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01546194
Message ID:
01546443
Views:
36
This works for me in Outlook.vba :
'------------------
Sub testSaveMails()
    Dim i As Integer
    i = 0
    For i = 1 To ActiveExplorer.CurrentFolder.Items.Count
        On Error Resume Next
        ActiveExplorer.CurrentFolder.Items(i).SaveAs "u:\_Temp\120620 outlook\item" & i & ".txt", OlSaveAsType.olTXT
        
        On Error GoTo 0
    Next i
End Sub
olTxt turns out to be 1. Maybe you should try it with 1 i.o. 0?




>>>>>>>>>>How can I save outlook messages as text files
>>>>>>>>>
>>>>>>>>>Use Automation and the SaveAs method of the MailItem object.
>>>>>>>>>
>>>>>>>>>Tamar
>>>>>>>>
>>>>>>>>Thanks for that but I am afraid i don't understand what you are getting at
>>>>>>>>
>>>>>>>>What is Automation in this context and what is the Mailitem object?
>>>>>>>>
>>>>>>>>Can you please give me an example in use
>>>>>>>
>>>>>>>You can automate Outlook, like this:
>>>>>>>
>>>>>>>
>>>>>>>LOCAL oOutlook, oNS, oInbox, oItem
>>>>>>>oOutlook = createobject('Outlook.Application')
>>>>>>>oNS = oOutlook.GetNameSpace('MAPI')
>>>>>>>
>>>>>>>oInbox = oNS.GetDefaultFolder[6]  && 6 is the main Inbox folder
>>>>>>>
>>>>>>>* Assuming you want the last item
>>>>>>>oItem = oInbox.Items[oInbox.Items.Count]
>>>>>>>
>>>>>>>* assumes you already set up name of output file in cFileWithPath
>>>>>>>oItem.SaveAs(cFileWithPath, 0) && 0 is txt type
>>>>>>>
>>>>>>>
>>>>>>>MailItem is the name of the class in Outlook used for individual emails.
>>>>>>>
>>>>>>>Tamar
>>>>>>
>>>>>>Tamar - thanks
>>>>>>
>>>>>>My code
>>>>>>
>>>>>>cFileWithPath="m:\outlook\dax"
>>>>>>
>>>>>>LOCAL oOutlook, oNS, oInbox, oItem
>>>>>>oOutlook = createobject('Outlook.Application')
>>>>>>oNS = oOutlook.GetNameSpace('MAPI')
>>>>>>
>>>>>>oInbox = oNS.GetDefaultFolder[6] && 6 is the main Inbox folder
>>>>>>
>>>>>>* Assuming you want the last item
>>>>>>oItem = oInbox.Items[oInbox.Items.Count]
>>>>>>
>>>>>>* assumes you already set up name of output file in cFileWithPath
>>>>>>oItem.SaveAs(cFileWithPath, 0) && 0 is txt type
>>>>>>
>>>>>>This comes up with an error on the last line Parameter no Optional
>>>>>>
>>>>>
>>>>>Make sure to include the filename you want in cFileWithPath.
>>>>>
>>>>>Tamar
>>>>
>>>>I did include the file name - this is my code
>>>>
>>>>cFileWithPath="m:\outlook\dax"
>>>>
>>>>LOCAL oOutlook, oNS, oInbox, oItem
>>>>oOutlook = createobject('Outlook.Application')
>>>>oNS = oOutlook.GetNameSpace('MAPI')
>>>>
>>>>oInbox = oNS.GetDefaultFolder[6] && 6 is the main Inbox folder
>>>>
>>>>* Assuming you want the last item
>>>>oItem = oInbox.Items[oInbox.Items.Count]
>>>>
>>>>* assumes you already set up name of output file in cFileWithPath
>>>>oItem.SaveAs(cFileWithPath, 0) && 0 is txt type
>>>>
>>>>This comes up with an error on the last line Parameter no Optiona
>>>
>>>Hmm. Just tested and I see this, too. I tried a couple of variations involving accessing the item more directly (rather than saving it to a local variable) and they didn't work either.
>>>
>>>Not sure what to suggest.
>>>
>>>Tamar
>
>Thanks for your help so far - let me know if you crack it

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Reply
Map
View

Click here to load this message in the networking platform