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.
Thread starter Similar threads Forum Replies Date
J Newbie needs help Outlook VBA and Custom Forms 2
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
J Newbie to Outlook--moving files off exchange server to local drive 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 Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconve Using Outlook 2
D Outlook Form Needs to move P2 to the Task Pane Using Outlook 2
H Outlook 2010 reminder needs to pop up Using Outlook 1
B seting up office outlook...during set up, a box showed STMP POP3 for sending emails, the recieving box was empty. What information needs to go into t Using Outlook 2
K Microsoft office outlook has encountered a problem and needs to close. We are sorry for the inconven Using Outlook 3
G Scanpst.exe error but can't find file that needs to be fixed due to outlook not opening up Using Outlook 3
D Outlook 2010 Conversation Feature - Needs another option Using Outlook 1
T What permissions needs for booking room in exchange 2010 Exchange Server Administration 6
T Re: What permissions needs for booking room in exchange 2010 Exchange Server Administration 2
W Microsoft has encountered a problem and needs to close. Using Outlook 3
M office 2007 - office outlook has encountered a problem...needs to close Using Outlook 3
G Office Outlook has encountered a problem and needs to close. Using Outlook 1
N Re: Outlook needs account access permission to open but doesnt work right after that. Using Outlook 2
B Exchange 2010 High Availability needs a SAN ?? Exchange Server Administration 2
R Microsoft Office Encountered a Problem and needs to close. Using Outlook 2
R Outlook 2003 email signature reverts to "none", needs to be reselected in options Using Outlook 2
A I get the following statement when I try to open Microsoft Outlook 'A program needs your attention to continue.' Using Outlook 1
A How best to handle shared email folder where history needs to be maintained Using Outlook 2
J Finding software for out office that meets our needs. Using Outlook 1
D "Microsoft Outlook has encountered a problem and needs to close. We are sorry for the inconvenience. Using Outlook 3
T Outllok 2007 needs to be restarted to receive email Using Outlook 5
K Microsoft Office Outlook has encountered a problem and needs to close. Using Outlook 3
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
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
Similar threads


















































Top