VBA Script to move item in secondary mailbox

Status
Not open for further replies.

Qaadir

Member
Outlook version
Email Account
Exchange Server
Hi

I have a script looking for a specific attachment name then forwarding it to a new recipient. Once this mail is sent it then has to move the original mail into a sub folder under the inbox.

This works when using it on my primary email account but I need this to run on a secondary account.

here is the code i have thus far please assist would be greatly appreciated.

Sub RequestForm(olItem As MailItem)
Dim olAtt As Attachment, ol_newmail As MailItem

For Each olAtt In olItem.Attachments

If InStr(1, Left(olAtt.FileName, 8), "FileName") > 0 Then

Set ol_newmail = olItem.Forward
ol_newmail.To = "newrecipient@email.com"
ol_newmail.Send
Exit Sub
End If
Next

End Sub

Sub MoveForm(Item As Outlook.MailItem)
For Each olkAtt In Item.Attachments
If Left(LCase(olkAtt.FileName), 8) = "filename" Then
Item.Move Session.GetDefaultFolder(olFolderInbox).Folders("DistinationFolder")
Exit For
End If
Next
Set olkAtt = Nothing
End Sub

Im assuming this is because I am using default folder but cant i just add the email account name somewhere within the Item.Move command
 
Hi Michael

Thank you for the reply i haven't been able to test as yet once I do I will revert back. I am relatively new to this so only playing around right now.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
A VBA Script - Print Date between first email in Category X and last email in Category Y Outlook VBA and Custom Forms 3
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
D.Moore VBA script fail after Office 365 update Using Outlook 8
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
dweller Outlook 2010 Rule Ignores VBA Script Outlook VBA and Custom Forms 2
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
K Outlook Archive to PST Files by Date Range VBA Script? Outlook VBA and Custom Forms 1
Peter H Williams Enable script containing VBA Outlook VBA and Custom Forms 12
R VBA Script Quick Parts Using Outlook 1
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
P How many subs can run in one outlook VBA script Using Outlook 5
J Email Parsing VBA Script for Outlook - NEEDED Outlook VBA and Custom Forms 7
P Vba script including macro appears in rules but wont run Outlook VBA and Custom Forms 6
R Adding vba to script list Outlook VBA and Custom Forms 4
F VBA script to highlight specific words Outlook VBA and Custom Forms 1
D VBA Script to extract text matching specific criteria Outlook VBA and Custom Forms 1
D VBA Script (Ask to where to save send mail) Outlook VBA and Custom Forms 1
M VBA script to allow mail merges of distribution groups? Using Outlook 7
D VBA script to auto download attachments and rename file according to subject line Outlook VBA and Custom Forms 23
Hudas Outlook VBA script reverting back to previous changes Outlook VBA and Custom Forms 2
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
V "Accept + Send the Response now", VBA script? Using Outlook 1
R Addins4Outlook TagIt! addin script or VBA module? Using Outlook 2
S Outlook VBA rule script to process both MailItem and MeetingItem Using Outlook 0
A VBA Script to Forward Spam to AntiSpam Provider Using "Blank" Form Outlook VBA and Custom Forms 2
L Limit VBA Script to one Outlook account Using Outlook 1
H using VBA to edit subject line Outlook VBA and Custom Forms 0
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
R Outlook 2019 VBA to List Meetings in Rooms Outlook VBA and Custom Forms 0
geoffnoakes Counting and/or listing fired reminders via VBA Using Outlook 1
O VBA - Regex - remove double line spacing Outlook VBA and Custom Forms 1
D.Moore Strange VBA error Outlook VBA and Custom Forms 4
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1
W Can vba(for outlook) do these 2 things or not? Outlook VBA and Custom Forms 2
MattC Changing the font of an email with VBA Outlook VBA and Custom Forms 1

Similar threads

Back
Top