M
mrsadmin
Hi there,
Diane has been an awesome help answering my questions on her blog series, but I thought I should come and post on the forums, (which are great) as I want to see about doing some more interesting tweaks to this code!
The situation:
I want to use the Macro MoveAgedMail2(with Case, new code) as a way to maintain my accounts (imap, non exchange) I have 5+ accounts which need housekeeping. Running this code is far superior to running "move message" rules as per outlook setup for what we need. I am also implementing it in my "Sent" items folder as a way to keep that maintained, rather than piecing together other custom macros.
This is my code - it works perfectly.
I tried to implement other code found: spiceworks edits
It allows movement based on "Sender" details. I can't get it to work, it defaults always to the last 'move' code:
What I'd like:
Setting up for multiple folder use, is it better to set up a number of Modules & name accordingly: MAMailMain(); MAMailSent() etc, then run a Master macro to call each of them (if the Master macro will run in the ThisOutlookSession) Or is there a more efficient way of setting this up?
Rather than SenderName, as from the 2nd site, I need to use email addresses as some of my senders have 2 emails, 1 autogen notices, 1 personal account, but they both use the same 'name'.
My problem now is that I don't know how to change naming conventions, what can be used (ie: SenderEmail vs SenderName, strRecipient vs strSender) I think its a stumbling block.
I am loving learning VBA. Diane has been a tremendous help and has been remarkably patient with my questions.
Thank you in advance.
MrsAdmin
Diane has been an awesome help answering my questions on her blog series, but I thought I should come and post on the forums, (which are great) as I want to see about doing some more interesting tweaks to this code!
The situation:
I want to use the Macro MoveAgedMail2(with Case, new code) as a way to maintain my accounts (imap, non exchange) I have 5+ accounts which need housekeeping. Running this code is far superior to running "move message" rules as per outlook setup for what we need. I am also implementing it in my "Sent" items folder as a way to keep that maintained, rather than piecing together other custom macros.
This is my code - it works perfectly.
Code:
Sub MoveAgedMail2()
'source: http://www.slipstick.com/developer/macro-move-aged-mail/
'Get the function from http://slipstick.me/qf
'Define outlook objects:
'removed due to 'submission error, length of post'
'set values
Set objSourceFolder = GetFolderPath("1 admin\inbox\1 dist\1 dist")
'brevity
Select Case obj.Class
Case olMail
sDate = obj.ReceivedTime
sAge = 3
Case olReport
sDate = obj.CreationTime
sAge = 10
Case Else
GoTo NextItem
End Select
'Perform logic to determine difference between NOW and the date of the item.
intDateDiff = DateDiff("d", sDate, Now)
If intDateDiff > sAge Then
'Use a folder in a different data file
Set objDestFolder = GetFolderPath("2 OLS\Inbox\9 Sort")
obj.Move objDestFolder
'brevity
NextItem:
Next
'brevity
End Sub
I tried to implement other code found: spiceworks edits
It allows movement based on "Sender" details. I can't get it to work, it defaults always to the last 'move' code:
Code:
'If Date is older than 0 days (or today) then apply the following logic
If intDateDiff > 0 Then
'Define Sender of item
strSender = objVariant.SenderName
If strSender = "Voicemail Sender" Then
Set obDestFolder = as above
objVariant.Move obDestFolder
moveOnce = 1
End If
[I] 'even with my code including moveOnce (or removed) it will always default to here:[/I]
If moveOnce = 0 Then
Set objDestFolder = GetFolderPath("2 account\Inbox\9 Sort")
objVariant.Move obDestFolder
End If
What I'd like:
Code:
If strRecipient = "email@address.com" Then
Set objDestFolder = GetFolderPath
objVariant.Move obDestFolder
End If
If Item.Categories = "Bus - Accs (Dist)" Then
Set objDestFolder = GetFolderPath
objVariant.Move obDestFolder
moveOnce = 1
End If
Setting up for multiple folder use, is it better to set up a number of Modules & name accordingly: MAMailMain(); MAMailSent() etc, then run a Master macro to call each of them (if the Master macro will run in the ThisOutlookSession) Or is there a more efficient way of setting this up?
Rather than SenderName, as from the 2nd site, I need to use email addresses as some of my senders have 2 emails, 1 autogen notices, 1 personal account, but they both use the same 'name'.
My problem now is that I don't know how to change naming conventions, what can be used (ie: SenderEmail vs SenderName, strRecipient vs strSender) I think its a stumbling block.
I am loving learning VBA. Diane has been a tremendous help and has been remarkably patient with my questions.
Thank you in advance.
MrsAdmin