![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hello,
I am trying to write a macro so that the attachment is saved to a specific folder and then a hyperlink is inserted to the saved document. From the help I got the below code to save the first attachment and I also saw som code to strip the email from the atchement but I couldn't find a way to insert a hyperlink. I am new to Office VBA and would appreciate anykind of help. Thanks, Ozgur Sub SaveAttachment() Dim myOlApp As Outlook.Application Dim myInspector As Outlook.Inspector Dim myItem As Outlook.MailItem Dim myAttachments As Outlook.Attachments Set myOlApp = CreateObject("Outlook.Application") Set myInspector = myOlApp.ActiveInspector If Not TypeName(myInspector) = "Nothing" Then If TypeName(myInspector.CurrentItem) = "MailItem" Then Set myItem = myInspector.CurrentItem Set myAttachments = myItem.Attachments 'Prompt the user for confirmation Dim strPrompt As String strPrompt = "Are you sure you want to save the first attachment in the current item to the C:\ folder? If a file with the same name already exists in the destination folder, it will be overwritten with this copy of the file." If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then myAttachments.Item(1).SaveAsFile "L:\" & _ myAttachments.Item(1).DisplayName End If Else MsgBox "The item is of the wrong type." End If End If End Sub |
#2
|
|||
|
|||
![]()
You can add a "shortcut" to a file using the olByReference Type as an
argument in the Attachments.Add method: objItem.Attachments.Add "C:\myfile.txt", OlAttachmentType.olByReference For a true hyperlink though, just insert text into the message body using the file:// protocol: fiile://C:\myfile.txt Both methods though presume the receiver has access to the file path, and that the location doesn't change. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Ozgur Pars" wrote: Hello, I am trying to write a macro so that the attachment is saved to a specific folder and then a hyperlink is inserted to the saved document. From the help I got the below code to save the first attachment and I also saw som code to strip the email from the atchement but I couldn't find a way to insert a hyperlink. I am new to Office VBA and would appreciate anykind of help. Thanks, Ozgur Sub SaveAttachment() Dim myOlApp As Outlook.Application Dim myInspector As Outlook.Inspector Dim myItem As Outlook.MailItem Dim myAttachments As Outlook.Attachments Set myOlApp = CreateObject("Outlook.Application") Set myInspector = myOlApp.ActiveInspector If Not TypeName(myInspector) = "Nothing" Then If TypeName(myInspector.CurrentItem) = "MailItem" Then Set myItem = myInspector.CurrentItem Set myAttachments = myItem.Attachments 'Prompt the user for confirmation Dim strPrompt As String strPrompt = "Are you sure you want to save the first attachment in the current item to the C:\ folder? If a file with the same name already exists in the destination folder, it will be overwritten with this copy of the file." If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then myAttachments.Item(1).SaveAsFile "L:\" & _ myAttachments.Item(1).DisplayName End If Else MsgBox "The item is of the wrong type." End If End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how do I insert a contact detail from a email attachment | chilli hot | Outlook - Using Contacts | 1 | October 29th 06 02:15 PM |
vba code that insert a hyperlink file in the body of message | gabriel | Outlook and VBA | 3 | April 24th 06 01:51 PM |
Shortcuts do not work when using Insert/File Attachment | Millicent | Outlook Express | 10 | March 14th 06 08:27 PM |
Insert Attachment - default folder | Cooler Dude | Outlook Express | 3 | March 5th 06 10:13 AM |
Insert a hyperlink to section of Word doc in an outlook message | [email protected] | Outlook - General Queries | 0 | February 8th 06 05:07 AM |