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
 

GingaDave

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2010
sorry - mistype in stampdate code - should read
Code:
Sub StampDate()
   Item.body = Now()
End Sub


Sub InsertDate_Click()
  Call StampDate()
End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
Thread starter Similar threads 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
L Using a template for new email message, changes are not saved unless I send the message...using Wind Using Outlook 3
P Cannot save new Outlook 2007 message as a Word template to share Building Blocks/Quick Parts Using Outlook 2
A Flag Message for Follow Up after sending Outlook VBA and Custom Forms 1
S Outlook (2016 32bit; Gmail IMAP) - Save sent message to Outllook Folder Outlook VBA and Custom Forms 0
C Why won't Title display in message list? Using Outlook 1
icacream content in this message could not be downloaded.... Using Outlook 2
J Outlook 2016 After a search in all mailboxes, where is each message that was found? Using Outlook 6
R Warn before sending message Outlook VBA and Custom Forms 4
T Column to display which email alias a message was sent to Outlook VBA and Custom Forms 6
V Change start time based on message duration Outlook VBA and Custom Forms 2
J Message search and edit, another way? Outlook VBA and Custom Forms 4
N VBA to delete duplicates by message-id on common pst for 2 or more emails Outlook VBA and Custom Forms 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
T Missing text in e-mail message after "(Please keep confidential)" Using Outlook 3
C Custom Form (seperate layout pages and message reading pane) Outlook VBA and Custom Forms 0
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
M Message list font changed after update Using Outlook 2
BretAB Is it possible to add a lookup field to a Message form? Outlook VBA and Custom Forms 4
D Unopened message in inbox deleted and not in deleted items Using Outlook 3
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh Cannot get Macro to SAVE more than one message attachment??? Outlook VBA and Custom Forms 5
W Message class changes of a custom form changes to the default form Using Outlook 2
evdbogaard Reply with only last message cited Using Outlook 1
T O365 and Office Message Encryption Exchange Server Administration 2
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
D Outlook Message Window Changes Size and Position Using Outlook 1
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
R Retain Original Message When Forwarding With Macro Outlook VBA and Custom Forms 3
R Call a Public Sub when a Flag is clicked on in the Message Preview pane Outlook VBA and Custom Forms 1
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
P Message List Font Changed Using Outlook 6
I Automating message move between folders Outlook VBA and Custom Forms 0
U Outbox Message Stuck after reading some MailItem Properties with VBA Outlook VBA and Custom Forms 1
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
R VBA macro - new message Outlook VBA and Custom Forms 3
I How to display sender's name instead of email address in outlook 2013 message Using Outlook 5
B Search: Cannot find which Folder Contains a Message Using Outlook 3
J Outlook 2016 message content does not display - outlook.com; exchange Using Outlook.com accounts in Outlook 9
E Search for folder by key in subject then move new message to related folder Outlook VBA and Custom Forms 1
D Paste Excel table into Outlook message Outlook VBA and Custom Forms 6
W Message Text Using Outlook 1
P Unread Until Click Another Message? Using Outlook 2
N Saving And Deleting Outlook Attachments with Unknown Error Message Outlook VBA and Custom Forms 1
Similar threads


















































Top