Message template / custom forms and VBA Help needed - inserting info into table

Status
Not open for further replies.

GingaDave

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2010
Hi, I'm stuck and i am needing help.

i have created a message template to be used for admin, but they want their lives made easier. Now the boss has asked me to sort it out.
Basically, the issue is this. Below is an image of the template. It was created in a table. at the moment the admin are filling in all fields themselves. Now they want some fields filled in automatically. The fields they want auto-filled are :


Date created: - Populates the date that the message was created.

ATTACHED FOR REFERENCE - This is a list of all of the attachments that have been attached to the email.

FILE PATH STRUCTURE ON SERVER - This is a list of the location where the attachments were inserted from. ( eg c:/jobs/5467/pdfs/drawing0042.pdf )

I have found some code from other places that help me to some point with the 1st field and 2nd field but not the 3rd field.

1st field - the code works (from Diana - thanks) but i need it to be in the correct cell.
Code:
Sub StampDate()
   Item.DTS1 = Now()
End Sub


Sub InsertDate_Click() 
  Call StampDate() 
End Sub

2nd field - this also needs to be in the correct cell, and also i cant seam to create a custom form button to run this script (would be nice if it was one button for all )
Code:
Sub Names()

Dim Atmt As Attachment
Dim Mensaje As Outlook.MailItem
Dim Adjuntos As String
Dim Body As String
Dim i As Integer


Set Mensaje = Application.ActiveInspector.CurrentItem
Mensaje.BodyFormat = olFormatHTML

Body = Mensaje.HTMLBody

i = 0
Adjuntos = ""

For Each Atmt In Mensaje.Attachments
    'If Atmt.Size > 5 Then
    Adjuntos = Adjuntos & "** Attached file: <u> " & Atmt.FileName & " </u> <br>"
    i = i + 1
    'End If
Next Atmt

Adjuntos = "<u> <b> Total number of attached files: " & i & "</u></b> <br>" & Adjuntos

Mensaje.HTMLBody = Left(Body, InStr(Body, "</body>") - 1) & Adjuntos & Right(Body, Len(Body) - InStr(Body, "</body>") + 4) & Format(Now)

Set Mensaje = Nothing

3rd field - Total loss - i need the code and button (again if was same button would be fab)


Cheers

GingaDave



upload_2015-2-7_14-33-9.png
 
sorry - mistype in stampdate code - should read
Code:
Sub StampDate()
   Item.body = Now()
End Sub


Sub InsertDate_Click()
  Call StampDate()
End Sub
 
Access user properties this way
Code:
item.userproperties("name").value = "abc"

As to the third issue, I don't know a way to get that info from Outlook. I think you'd need to write the part to add the attachment to the email yourself. If you drag an item to the email, the file path is available in the clip board.
 
The date stamp code is vbscript and added to the form. To the best of my knowledge, you can't work with cells using vbscript. You can do it in word using VBA - so as long as you are using VBA and not a script in the custom form, you might be able to get it into the cell. (Command buttons on forms use VBscript... )

This is the code i use in Word to read the cell in the first row, 3rd column in the first table. In a quickie test the other day, I tried converting it to Outlook but didn't get the tables referenced right.
Code:
Dim myTable As Word.Table
Set myTable = ActiveDocument.Tables(1)
txtNotes = myTable.Cell(1, 3)

Making your other macro work with a command button starts with changing the name to match the button name - like the Sub InsertDate_Click() is named. I believe this only works with vbscript (Michael will correct me, if I'm wrong). If so, you would need to convert the macro to script - there are subtle differences between vbscript and VBA and not everything is supported. I haven't looked closely at your code to know if it will work in vbscript. It is possible to call vba from a script, but it's not something microsoft recommends (plus the form is no longer self-contained and not as easily shared).
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R How to design custom template under message/mail form ! Using Outlook 0
L reply to message using a custom template Using Outlook 1
N Creating or changing the main new mail message template in Outlook 2010 Using Outlook 2
J Adding original email text to outlook message template Outlook VBA and Custom Forms 2
J New e-mail message template Using Outlook 1
N How to automatically update all fields in an Outlook message template (OFT)? Using Outlook 9
E "The operation cannot be performed because the message has been changed" Using Outlook 3
G Reply a selected message and remove blank space before signature Outlook 365 version 2406 64BIT Outlook VBA and Custom Forms 2
G Reply a selected message and remove blank space before signature Outlook 365 version 2406 64BIT Outlook VBA and Custom Forms 0
D Outlook 365 Outlook Message "Cannot be sent because the message has changed" Using Outlook 0
B Please remind me how I added this message button Outlook VBA and Custom Forms 0
E PgUp and PgDn don't work for displayed message content (but do for web pages) Using Outlook 4
M A plug in (or method) to keep email message formatting after it expires Using Outlook 1
Rob Can't save MailItem because the message changed in .pst file Outlook VBA and Custom Forms 0
M Search message, then (1) Jump to folder & (2) Select message that you searched for Outlook VBA and Custom Forms 6
Kika Melo How to mark as Junk any message not from Contacts (in Outlook.com) Using Outlook 3
G Outlook 365 My iCloud Outlook doesn’t work after reinstalling Microsoft365 on Windows 10 PC – now I get error message on contacts and calendar Using Outlook 1
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
HarvMan Outlook 365 - Rule to Move an Incoming Message to Another Folder Using Outlook 4
F Outlook 2019 Forwarding Message and Keeping Unread Status Outlook VBA and Custom Forms 0
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
C Populate form data into message body Outlook VBA and Custom Forms 1
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
B How to create a button that sorts and selects the most recent message with ONE click Using Outlook 2
P "Item could not be moved" message occurs frequently for IMAP inbox, Office 365 Using Outlook 0
A rule name into message - how? Outlook VBA and Custom Forms 5
A Links in email getting error message about group policy Using Outlook 4
O How to find and replace a word in Outlook-Agenda-Subject and Message? Using Outlook 0
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
Commodore Unable to move message Using Outlook 3
Y Disable Microsoft Outlook Test Message Using Outlook 4
S Unable to change Message Class Outlook VBA and Custom Forms 0
S Changing Message Class Outlook VBA and Custom Forms 4
Cathy Rhone Mail merge error message Using Outlook 1
C Can't Locate an Unread Message in my Outlook view pane Using Outlook 0
G Send a greeting message to a contact on birthday Outlook VBA and Custom Forms 5
B Inconsistent handling of message read/unread status by Outlook Using Outlook 3
N Save Selected Email Message as .msg File Outlook VBA and Custom Forms 12
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
Cathy Rhone The properties of the message have been changed Using Outlook 1
S Outlook 2016 A Shortcut to recall and delete and sent message. Using Outlook 1
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
S Unable to extract text from an Outlook email message Using Outlook 2
R Outlook 2016 Message-ID oddity/inconsistency? Using Outlook 7
J Implement Keywords based on body message Outlook VBA and Custom Forms 0
C must select message to trigger safe list Using Outlook 3
Witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
D.Moore VB script to Digitaly Sign newly created outlook message Outlook VBA and Custom Forms 2

Similar threads

Back
Top