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
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 I am having the problem that Outlook 2010 is checking for email via send /receive approximately every thirty seconds. Using Outlook 2
C 20 Seconds to Display Messages in Folder in Outlook 2007 Using Outlook 2
D Opening files in Mail Folders takes 15 seconds - running slow ? Using Outlook 4
J outlook 2007 hangs on send/receive on intial start up with 5 seconds left Using Outlook 7
J Outlook 2007 conducts send/receive every 35 seconds, even though it is set for 30 minutes Using Outlook 5
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
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
A Add multiple servers "on behalf of" email to "safe senders" list. Using Outlook 1
S Add Exchange Account as Secondary to Existing PST? Exchange Server Administration 1
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
A Add to Outlook Contacts from email - default view Outlook VBA and Custom Forms 1
P Add a contact to the New Task in Outlook 2016 Using Outlook 2
e_a_g_l_e_p_i Is there a way to add something that is in the "Format Text" tab to the "basic Text" on the message tab Using Outlook 1
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3

Similar threads

Top