Newbie needs help

Status
Not open for further replies.
J

Jim

I am trying to save the body of an email to a text file using vba code

Would someone kindly post the code so that I can use it as a worked example

I'm using WinXP and Outlook 2003

Regards & TIA
 
C

Charlize

VBA Code:

------------------
Sub save_selection_mails_to_txt()

'The message you want to process

Dim MyMessage As Outlook.MailItem

'a number

Dim myItem As Long

Dim save_it As String

'if selection isn't present, don't do a thing

'you could build an extra check if the class

'of the selected item is a message or not

'because there are read receipt and taskitems in mailbox

If ActiveExplorer.Selection.Count < 1 Then

MsgBox "Select at least one mailmessage", vbInformation

Exit Sub

End If

For myItem = 1 To ActiveExplorer.Selection.Count

Set MyMessage = ActiveExplorer.Selection.item(myItem)

save_it = MyMessage.ReceivedTime

'when using dates with /

save_it = Replace(save_it, "/", "_")

'when using hours with :

save_it = Replace(save_it, ":", "-")

'c:\txt-mails must be present as a directory

MyMessage.SaveAs "c:\txt-mails\" & save_it & " -- " & MyMessage.SenderName & ".txt", olTXT

'go to next selected mail

Next myItem

End Sub

------------------
Charlize
 
J

Jim

Many thanks ... That is exactly what I needed to get me started.

Regards

Jim
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
J Newbie confusion Using Outlook 0
E Newbie, desperately seeking help Using Outlook 2
S Seperating email accounts, Syncronizing, and a few newbie questions Using Outlook 5
C Newbie import issues Using Outlook 3
J Newbie to Outlook--moving files off exchange server to local drive Using Outlook 3
A General, how to get started? [kwrds begin start newbie] Outlook VBA and Custom Forms 3
R Newbie Redemption ISafeMailItemPtr question Outlook VBA and Custom Forms 6
R Newbie get_CurrentItem() question Outlook VBA and Custom Forms 6
Y Newbie : What is http://schemas.microsoft.com all about? Outlook VBA and Custom Forms 2
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
lotsbg Loads of junk in second email needs fixing Using Outlook 1
R Narcotics Police Officer Needs help Using Outlook 1
Y Changing colour of selection bar in Outlook (too light, needs to be grey) Using Outlook 4
J Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconve Using Outlook 2
D Outlook Form Needs to move P2 to the Task Pane Using Outlook 2
H Outlook 2010 reminder needs to pop up Using Outlook 1
B seting up office outlook...during set up, a box showed STMP POP3 for sending emails, the recieving box was empty. What information needs to go into t Using Outlook 2
K Microsoft office outlook has encountered a problem and needs to close. We are sorry for the inconven Using Outlook 3
G Scanpst.exe error but can't find file that needs to be fixed due to outlook not opening up Using Outlook 3
D Outlook 2010 Conversation Feature - Needs another option Using Outlook 1
T What permissions needs for booking room in exchange 2010 Exchange Server Administration 6
T Re: What permissions needs for booking room in exchange 2010 Exchange Server Administration 2
W Microsoft has encountered a problem and needs to close. Using Outlook 3
M office 2007 - office outlook has encountered a problem...needs to close Using Outlook 3
G Office Outlook has encountered a problem and needs to close. Using Outlook 1
N Re: Outlook needs account access permission to open but doesnt work right after that. Using Outlook 2
B Exchange 2010 High Availability needs a SAN ?? Exchange Server Administration 2
R Microsoft Office Encountered a Problem and needs to close. Using Outlook 2
R Outlook 2003 email signature reverts to "none", needs to be reselected in options Using Outlook 2
A I get the following statement when I try to open Microsoft Outlook 'A program needs your attention to continue.' Using Outlook 1
A How best to handle shared email folder where history needs to be maintained Using Outlook 2
J Finding software for out office that meets our needs. Using Outlook 1
D "Microsoft Outlook has encountered a problem and needs to close. We are sorry for the inconvenience. Using Outlook 3
T Outllok 2007 needs to be restarted to receive email Using Outlook 5
T When outlook opens starts send/receive it freezes up than a window pops up stating an error has occurred and outlook needs to shut down Using Outlook 1
T Our helpdesk needs the right to grant the 'send as a public folder' right ... Exchange Server Administration 7
M What needs to be backed up? Exchange Server Administration 5
J Microsoft Outlook has encountered a problem and needs to close Using Outlook 8
K Microsoft Office Outlook has encountered a problem and needs to close. Using Outlook 3
J SyncServer has encountered a problem and needs to close Using Outlook 3
C MS Office Outlook has encountered a problem and needs to close. Using Outlook 0
J To-do bar needs to show appointments from multiple calendars Outlook Wishlist 3
C Beginner Needs VBA Help in Modifying Code Outlook VBA and Custom Forms 2
Forum Admin What needs fixing in Outlook? Outlook Wishlist 18
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
O Help .. got lost ... installing Office like 2016 Using Outlook 5
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
Similar threads


















































Top