Solved

Email Templates / Quick Attachments

Posted on 2014-01-28
12
362 Views
Last Modified: 2014-02-12
Hello Experts,

I often reply/start new emails to customers, which I need to send specific attachments.

Right now, all of the attachments (files) are located on a corporate network folder in which I drag the files into the email to attach.  Yes, doing so is very easy as it is - but is there an even easier way of doing so?

Ideally, I would love to have a series of buttons - (Example: 'Custom Capabilities', 'Credit Application') along the top of the email (I think it's called the ribbon?) - where I just click the button and it automatically adds the attachment, without me having to navigate or select it myself.

Is this even possible?

Thank you in advance for your help!
~ Geekamo
0
Comment
Question by:Geekamo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39818098
Hi, Geekamo.

Yes, that's possible if you have outlook 2010 or later.  To do this you need a few simple macros to handle adding the attachments.  You can then add the buttons to the ribbon yourself and connect each button to the correct macro.  Each macro would be something like this.

Sub AddCustomCapabilitiesAttachments()
    Dim olkMsg As Outlook.MailItem
    Set olkMsg = Application.ActiveInspector.CurrentItem
    'Add a line like the following for each file you want to attach
    olkMsg.Attachments.Add "\\server\share\file1.doc"
    olkMsg.Attachments.Add "\\server\share\file2.doc"
    Set olkMsg = Nothing
End Sub

Open in new window


All you need to do is duplicate this macro, change it's name, and add/change the names of the files you want to attach.  

If you have Outlook 2007, then something similar is possible, only instead of adding buttons to the ribbon you'll add them to the quick action toolbar.
0
 
LVL 1

Author Comment

by:Geekamo
ID: 39818586
@ BlueDevilFan,

I haven't tested this yet, but is it possible to return an error message if,...

1.) The folder location is not available.
2.) The file itself is not there.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39818794
Yes, that's possible.  Something like this

Sub AddCustomCapabilitiesAttachments()
    'On the next line enter the list of files (to include path) of the files you want to attach.
    'Each file must be separated from the previous filename by a comma.
    'Do not put a space after the comma.
    Const FILES_TO_ATTACH = "\\server\share\file1.doc,\\server\share\file2.doc"
    Const MACRO_NAME = "Fast Attach"
    Dim olkMsg As Outlook.MailItem, objFSO As Object, arrFiles As Variant, varFile As Variant, strFolder As String, strFile As String
    Select Case TypeName(Application.ActiveWindow)
        Case "Inspector"
            Set olkMsg = Application.ActiveInspector.CurrentItem
            arrFiles = Split(FILES_TO_ATTACH, ",")
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            For Each varFile In arrFiles
                strFolder = objFSO.GetParentFolderName(varFile)
                strFile = objFSO.GetFileName(varFile)
                If objFSO.FolderExists(strFolder) Then
                    If objFSO.FileExists(varFile) Then
                        olkMsg.Attachments.Add varFile
                    Else
                        MsgBox "I could not find a file named '" & strFile & "' in the folder '" & strFolder & "'.", vbCritical + vbOKOnly, MACRO_NAME
                    End If
                Else
                    MsgBox "I could not find a folder named '" & strFolder & "'.", vbCritical + vbOKOnly, MACRO_NAME
                End If
            Next
        Case Else
            MsgBox "You must have a message open before you can attach anything to it.", vbCritical + vbOKOnly, MACRO_NAME
    End Select
    Set olkMsg = Nothing
End Sub

Open in new window

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 1

Author Comment

by:Geekamo
ID: 39825806
@ BlueDevilFan,

Thank you for your replies.  I finally have free time (yay, the work week is over!)  Now I can finally test this out.  I will keep you posted.

~ Geekamo
0
 
LVL 1

Author Comment

by:Geekamo
ID: 39825812
@ BlueDevilFan,

I have added the code,...

Sub AddCustomCapabilitiesAttachments()
    Dim olkMsg As Outlook.MailItem
    Set olkMsg = Application.ActiveInspector.CurrentItem
    'Add a line like the following for each file you want to attach
    olkMsg.Attachments.Add "C:\Users\jburke\Desktop\Files\yourfile.png"
    olkMsg.Attachments.Add "\\server\share\file2.doc"
    Set olkMsg = Nothing
End Sub

Open in new window


And added a button to my New Email messages, and when I click on the button to execute the macro - nothing happens.

Any ideas?

~ Geekamo
0
 
LVL 1

Author Comment

by:Geekamo
ID: 39825873
@ BlueDevilFan,

I don't know if this will help you in troubleshooting the code not working for me, but I did a Google search and found code for this.  The only problem, it doesn't do "exactly" what I want it to do.  But it "does" work.

Sub AddAttachment()
 Dim myItem As Outlook.MailItem
 Dim myAttachments As Outlook.Attachments
 
 Set myItem = Application.CreateItem(olMailItem)
 Set myAttachments = myItem.Attachments
 myAttachments.Add "C:\Users\jburke\Desktop\Files\yourfile.png", _
 olByValue, 1, "Test"
 myItem.Display
End Sub

Open in new window


The code above, does add the file - without any problem.  But,..  it only does this by creating a new email message.  I would like this code to work on an email that is already open.  So basically, I plan to only execute the code from the ribbon menu on a new email item.

Also, the code above doesn't account for multiple files I may attach.

Thank you in advance for your help!

~ Geekamo
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39826448
Geekamo,

I just re-tested the solution and it worked perfectly.  The code you found on Google doesn't help.  It's doing exactly the same thing that my code does, it's just doing it in a slightly different way.  

What happens when you run my solution?  Are you sure the code is running?  What message format (e.g. HTML, Rich Text) are you using for your messages?
0
 
LVL 1

Author Comment

by:Geekamo
ID: 39831684
Hmm, I'm not technically sure if your code ran.  But I wasn't doing anything different then I was in the code that did work.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39832043
How about my other question?  What message format are you using for your messages?
0
 
LVL 1

Author Comment

by:Geekamo
ID: 39832336
its rich text or html.  not sure what its called, but its not the plain text i know that.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39835191
Rich Text and HTML handle attachments in different ways.  Please check to see which format it is.  You can do that by creating a message and looking at the top of the window the new message is in.
0
 
LVL 1

Author Comment

by:Geekamo
ID: 39837669
It's html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question