Change Subject of 500 mails sitting in Outbox with Macro

Status
Not open for further replies.

Jacques

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
My invoicing/billing system creates invoices which are sent to my outbox. All of the invoices have the same Subject except that the invoice number is at the end = "Tax Invoice INXXXXX". I usually disable my internet connection and then move the 500+ invoices to a sub-folder linked to my Outbox/Bulk Mail prior to running the invoices-program. I would like to run a macro to rename or add the words "PROFICIO" to "Tax Invoice INXXXXX" and have tried this with the scripts online. The problem is I cannot run them with rules as there is no sending rule linked to scripts only receiving rules. It should be a very simple Macro telling the program to Amend all files in the "Bulk Mail" folder and to add the words "PROFICIO" to "Tax Invoice INXXXXX". Once this is done I need to send all the files in the "Bulk Mail" folder. When I move them they are open and I have to edit and send them individually.

Your assistance and direction would be highly appreciated. Thanking you in advance.
 

Jacques

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Thanks Diane - The mails are not added with a mail-merge but via a 3rd party accounting software. I am not very clued up with Outlook VBA and use Excel VBA quit often. Can you perhaps help with the Complete Macro I need to run in Outlook VBA? My main problem is directing the Macro to the specified Folder where the emails are located. Thanks Jacques
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
As long as Outlook is sending the messages, it should work regardless of how it hits the outbox - it grabs messages as they hit the outbox.

To change the subjects in a folder, you need to loop through each message - this *should* work on drafts - it's from Add a file number or keyword to the subject line of messages and was designed for received messages. I think adding an aItem.Send after the save would send it for you too. (I didn't test it either using it on drafts or sending drafts, will do that next.)

Sub ChangeSubject()

Dim myolApp As Outlook.Application

Dim aItem As Object

Set myolApp = CreateObject("Outlook.Application")

Set mail = myolApp.ActiveExplorer.CurrentFolder

Dim iItemsUpdated As Integer

Dim strTemp As String

iItemsUpdated = 0

For Each aItem In mail.Items
strTemp = "Keyword" & aItem.Subject
aItem.Subject = strTemp
iItemsUpdated = iItemsUpdated + 1
aItem.Save

Next aItem

MsgBox iItemsUpdated & " of " & mail.Items.Count & " Messages Updated"

Set myolApp = Nothing

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Ok... Adding aitem.send works BUT it only sends half, need to do a negative loop to count down and send all.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
ok - this sends most of the messages - for some reason, some fail with an error about inline messages (I'm using 2013) - on error resume next with send what it can and leave the rest.

Sub ChangeSubject()

Dim myolApp As Outlook.Application

Dim aItem As Variant 'As Object

Set myolApp = CreateObject("Outlook.Application")

Set mail = myolApp.ActiveExplorer.CurrentFolder.Items

Dim i As Long

Dim strTemp As String

Dim intCount As Integer

On Error Resume Next

intCount = mail.Count

For i = intCount To 1 Step -1

Set aItem = mail.Item(i)
strTemp = "a " & aItem.Subject
aItem.Subject = strTemp
aItem.Save
aItem.Send

Next i

Set myolApp = Nothing

End Sub
 

Jacques

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Thanks a million Diane! I did a test on 10 mails and it works great!:)
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
I change subject and forward without FW: Outlook VBA and Custom Forms 4
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
E Button to change subject Outlook VBA and Custom Forms 1
Aussie I Change the Subject Line ... but after it is moved the subject has reverted Using Outlook 1
P Subject change on selected emails Outlook VBA and Custom Forms 14
A Change a subject after I hit send Using Outlook 1
F VBA Code to change subject Like Outlook VBA and Custom Forms 3
P Automatically 'Reply to all', and Change the Subject of Email - Diane P help! Using Outlook 0
A Change subject line of external software using outlook. Using Outlook 1
V rule to Find some words in the subject, change subject then forward Using Outlook 1
M rule to change subject, pull email addresses from body, and forward with templ Using Outlook 14
L Script to: Change subject of email after checking body Using Outlook 2
J Change the subject line of messages in public folders Using Outlook 3
J Public folders woes (script to change subject line of messages) Exchange Server Administration 0
M Change font of from/to/subject block Using Outlook 1
S Change "This Week" flag start date behavior Using Outlook 1
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
D Change Microsoft Account password - what to do to update on all devices Using Outlook 4
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R How to Change Margins In Google Docs...? Using Outlook 0
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 10
B Change row background color of selected item Using Outlook 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
B See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
R Folder pane width change Using Outlook 76
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
S Outlook 2010 unable to change default font Using Outlook 7
P How can I change my calendar view back Using Outlook 3
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
CWM030 Name Change? Exchange Server Administration 9

Similar threads

Top