A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Code not moving through messages



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old November 13th 09, 12:46 AM posted to microsoft.public.outlook.program_vba
PJFry
external usenet poster
 
Posts: 14
Default Code not moving through messages

The code below archives my messages into a local folder. What I want to do
is to have each message stamped with an 'Archived' noted so I know it has
already been done and have the code skip that message.

The problem I am having is that the 'Archived to" string is only inserted
into the message body that I have selected when I exectute the code. If I
have no messages select, none of them are altered.

The messages save ok, but what am I missing that keeps the itm.Body from
being updated?

Sub SaveMessages()

Dim OL As Application
Dim NmeSpace As NameSpace
Dim SubTxt As String

Set OL = CreateObject("Outlook.Application")
Set NmeSpace = OL.GetNamespace("MAPI")
Set Inbx = NmeSpace.GetDefaultFolder(olFolderInbox)
Set fldr = Application.ActiveExplorer.CurrentFolder
DirName = "C:\Documents and Settings\PJFry\Email\"

For Each itm In fldr.Items

SubTxt = itm.Subject
SubTxt = Replace(SubTxt, "_", "")
SubTxt = Replace(SubTxt, "´", "'")
SubTxt = Replace(SubTxt, "`", "'")
SubTxt = Replace(SubTxt, "{", "(")
SubTxt = Replace(SubTxt, "[", "(")
SubTxt = Replace(SubTxt, "]", ")")
SubTxt = Replace(SubTxt, "}", ")")
SubTxt = Replace(SubTxt, "/", "-")
SubTxt = Replace(SubTxt, "\", "-")
SubTxt = Replace(SubTxt, ":", "")
SubTxt = Replace(SubTxt, ",", "")
'Cut out invalid signs.
SubTxt = Replace(SubTxt, "*", "'")
SubTxt = Replace(SubTxt, "?", "")
SubTxt = Replace(SubTxt, """", "'")
SubTxt = Replace(SubTxt, "", "")
SubTxt = Replace(SubTxt, "", "")
SubTxt = Replace(SubTxt, "|", "")


FNme = DirName & Trim(SubTxt) & " " & Format(itm.ReceivedTime,
"yy.mm.dd") & " " & itm.SenderName & ".msg"

If itm.Class = olMail Then
If InStr(1, itm.Body, "Archived to") 0 Then
'do nothing
Else
itm.Body = itm.Body & vbCrLf & _
"Archived to " & DirName & " on " & Now()
itm.SaveAs FNme, olMSG
End If
End If


Next itm


End Sub


If there is a better way to accomplish the same thing, I would also love to
hear it.

Thanks!

PJ
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Messages Automatically Antiherome Outlook - Installation 4 June 23rd 09 06:18 PM
Code for moving Sent Items depending on From Field SueD Outlook and VBA 0 October 7th 08 11:37 AM
moving messages shakey Outlook Express 4 March 6th 08 08:14 PM
Code modification help for moving SCrowley Outlook and VBA 1 May 11th 07 07:07 PM
Moving OE messages around History Fan Outlook Express 4 March 25th 07 09:15 PM


All times are GMT +1. The time now is 09:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.