Newbie needs help with Outlook Macro

Status
Not open for further replies.

chrisk2305

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Hi Guys,

My Goal is create a Outlook Macro that adds the date into the subject line of every email for the following occasions:
Every email that arrives
Every new Email I create
Every Email I answer or forward

The Subject should look like: "2016-05-11 This is a test"

My first try was to create a script rule for incoming emails. The script contains the following code:

Code:
Sub ChangeSubject()
Dim myolApp As Outlook.Application
Dim aItem As Object

Set myolApp = CreateObject("Outlook.Application")
Set mail = myolApp.ActiveExplorer.CurrentFolder

For Each aItem In mail.Items
      aItem.Subject = "Date" & aItem.Subject
    aItem.Save
    
 
Next aItem
End Sub

The code was actually copied from this side. But actually nothing happens and I have no idea how to debug. Can you guys help a noob? :)

Thanks in advance!
Christian
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It works on the selected folder, but is not what you want - it adds Date to the subject line:
DateOutlook Tip for May 9 2016

I'm assuming you want something more like this;
5/11/2016 Outlook Tip for May 9

which is set by this:
aItem.Subject = Date & " " & aItem.Subject
Date = today's date - if you want the received date:
2016-05-09 Outlook Tip for May 9 2016
use
aItem.Subject = Format(aItem.ReceivedTime, "yyyy-mm-dd") & " " & aItem.Subject

But... this macro is one you need to manually run. If you do that, you need to check the messages to see if the date was already added, otherwise, you'll add it to every message in the folder.

If you want it done automatically, you need an itemadd macro.
How to use an ItemAdd Macro


There is an itemsend mail here - Add a keyword to the subject of all messages sent - that can be tweaked to add the date.
 

chrisk2305

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
alright, got everthing working so far. But i have one question: How is it possible to answer an email that already has the date in the subject and replace it with date of answering event and also to replace an exisiting date upon receiving with the current date. I hope I could make clear what I want to achieve. Thanks in advance!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Newbie needs help Outlook VBA and Custom Forms 2
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
J To-do bar needs to show appointments from multiple calendars Outlook Wishlist 3
C Beginner Needs VBA Help in Modifying Code Outlook VBA and Custom Forms 2
Forum Admin What needs fixing in Outlook? Outlook Wishlist 18
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
S help with outlook scripting Outlook VBA and Custom Forms 4
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
EmelineGueguen Help to understand the problem of work Using Outlook 1
N Outlook Forms Help Outlook VBA and Custom Forms 2
N Need help syncing contacts to iPhone X Using Outlook 8
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
J Help! My contacts have disappeared. Using Outlook 5
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
J Help Needed With Multi-Step Login Email Address Using Outlook.com accounts in Outlook 1
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
G [Help] Converting array to destination folder path Outlook VBA and Custom Forms 1
K Help.... Office Outlook 2016 Using Outlook 1

Similar threads

Top