Get the seconds with userproperties.add method VBA Outlook

Status
Not open for further replies.

Nravota

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi Everyone and thanks in advance for your help,

I am trying to create a user-defined custom field with the userproperties.add method in vba outlook.

The idea is that when the user clicks on a macro button the field will show the current time with seconds included. I made the user-defined field with VBA Outlook but It gives the time with the following format, e.g. Thu 05/11/2015 09:23. I want to see the seconds as well

I created another user-defined field with Settings -> Columns -> ADD -> Test 1 with the idea to format UserDefinedFieldName to give the seconds. On the column properties I added: Format([UserDefinedFieldName],"ddd yyyy-mm-dd hh:mm:ss"). However it gives 0 seconds, which is not correct: Thu 05/11/2015 09:23:00.

How can I make a userdefined field which can give the seconds? Here is the code:

Code:
Dim UserDefinedFieldName As String
 
Set Folder = ActiveExplorer.CurrentFolder
 
If Folder.DefaultItemType = olMailItem Then
                Set Selection = ActiveExplorer.Selection
                    If Selection.Count > 0 Then
                        For i = 1 To Selection.Count
                        Set oEmail = Selection(i)
                        Set objProperty = oEmail.UserProperties.Add(UserDefinedFieldName, Outlook.OlUserPropertyType.olDateTime)
                        objProperty.Value = Now()
                        oEmail.Save
                        End Sub


Please help me get the seconds! Any help will be much appreaciated!
 

Nravota

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi Diane,

I do not need two fields, I just looked for another way to solve this but it works only with non-user-defined columns such as received.

I am not sure what you mean by value, for the field created invba outlook I use the =now() formula only. I do not know how to properly format it to include seconds.
 

Nravota

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
I also tried
Code:
objProperty.Value = vbLongTime
But it gives: 02/01/1900 00:00 :(. Is there a way to show current time with seconds?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It's something with the oldatetime field type that it drops the seconds. Do you need it as a date time field? If oltext will do, this works:
objProperty.Value = Format(Now(), "mm/dd/yyyy hh:mm:ss AM/PM")
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T E-mails marked as read turn back to unread after a couple of seconds Using Outlook 1
Venkata Murugan Guna How to sum hours, minutes, or seconds in Outlook Using Outlook 51
G Enter Network Password box pops up every few seconds Using Outlook 2
R How many seconds usually takes an email to get to an outlook account? Using Outlook 0
R Outlook 2007 Freezes (Pauses) Every 30 Seconds Using Outlook 2
N Cut and Paste Taking 25 seconds Using Outlook 0
D Cannot populate certain UserProperties in Outlook from Excel Outlook VBA and Custom Forms 2
W Appointment userproperties disappear Outlook VBA and Custom Forms 4
J Storing userproperties to array Outlook VBA and Custom Forms 4
mrmmickle1 UserProperties VBA to move message to another folder Outlook VBA and Custom Forms 7
R How to search for blank userproperties field Outlook VBA and Custom Forms 4
M Assigning Values to Contact UserProperties Outlook VBA and Custom Forms 1
S UserProperties of MailItem object. Outlook VBA and Custom Forms 3
V Difference between UserProperties and ItemProperties? Outlook VBA and Custom Forms 4
P Add inanimate objects to meetings? Using Outlook 1
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
BartH Add a string to the conditions in .Conditions.BodyOrSubject.Text Outlook VBA and Custom Forms 2
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
D Do I need Exchange Add-In? Using Outlook 6
C-S-R Manage Add-ins (Remove Wunderlist) Using Outlook 6
A iCloud add in problems Using Outlook 4
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 8
C Looking for feedback on new Outlook Add-in Using Outlook 0
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
S Add VBA save code Using Outlook 0
P Shortcut Pane - add shortcut to Office365 group mailbox Using Outlook 1
B Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
O Outlook tasks - Add text column with multiple lines Using Outlook 3
W April 2020 Office 365 Update - Add-Ons fail after Office 365 Update Using Outlook 6
B Task Filter Not Working When I add too many criteria Using Outlook 0
D Add date next to day name in Outlook Today calendar view Using Outlook 1
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
P Add Paste Unformatted to QAT Using Outlook 1
M Ignore slow add-ins Using Outlook 0
B Add Prefix text to Subject Line Using Outlook 1
Jennifer Murphy Add birthdays to calendar Using Outlook 7
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4
P Add, remove, & reorder folder pane Using Outlook 6
L Tired of Outlook disabling Adobe PDF Creator add-in Using Outlook 1
R Add 'Company' to Select Names Form Using Outlook 1
A Outlook 2016 Web add-in missing on some machines Using Outlook 9
P Syncing problems with add-ins Using Outlook 3
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
BretAB Is it possible to add a lookup field to a Message form? Outlook VBA and Custom Forms 4
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
iwshim outlook 2013 - I cannot see the "Manage Add-ins" Using Outlook 2

Similar threads

Top