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
 
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
 
Many thanks ... That is exactly what I needed to get me started.

Regards

Jim
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
O Newbie question: how to sync two Outlook -Exchange and IMAP- calendars? Using Outlook 4
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
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
C Beginner Needs VBA Help in Modifying Code Outlook VBA and Custom Forms 2
S Custom Contact card - need help creating one Outlook VBA and Custom Forms 1
D Lifelong Windows user - new to Mac - Help!!! Using Outlook 3
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
Nufc1980 Outlook "Please treat this as private label" auto added to some emails - Help. Using Outlook 3
I Help with Smart Folder + Query Builder on IMAP Using Outlook 0
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
A Outlook 2019 Help with forwarding email without mentioning the previous email sender. Outlook VBA and Custom Forms 0
Witzker Outlook 2019 HELP to get Template Path in a Function Outlook VBA and Custom Forms 2
CWM550 Outlook 365 HELP! Calendar Craziness! Using Outlook 5
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Has nobody used Office 2021 enough to help me or have you given up on me.......lol Using Outlook 1
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
L Help connecting to hosted exchange server 2016 Using Outlook 0
B Seeking help with Outlook rule Using Outlook 2
D Need help with MS Authenticator Using Outlook 4
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
S.Champ Please help? I've imported a random workcalendar I dont even know who's. Can I undo it? and then I need to re-sync the google one again. Its a mess:( Using Outlook 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
F Microsoft Outlook Connector 14.0.6123.5001 - Help! Using Outlook 6
Witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
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
I Help with dates in task list. Using Outlook 5
C need help setting up outlook first time Using Outlook 1
K To do bar help Using Outlook 8
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5

Similar threads

Back
Top