PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: Outkook 2000 - Inserting a link to a file on disk in a mail message
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: Outkook 2000 - Inserting a link to a file on disk in a mail message
![]() |
Re: Outkook 2000 - Inserting a link to a file on disk in a mail message |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Mr. Daniel,
That's exactly the simplest solution I thought of to circumvent that limitation of Outlook. The only part of the code I would need is the one that creates the shortcut of the file. This is a windows function... Do I have to use a FileSystemObject as the one we use to ckeck if a folder or a file exist? I sure will check it out. The rest of the code a kind of straight forward. But I still have a couple of questions... You say that you also add a hyperlink to the file in the body of the message. But isn't that just the same as adding a file (an attachment) with the option olByReference? I never saw the Ctrl-k option available in a mail message (as it is in Word, Excel, etc.)? How do you do that? I thought I would simply add a piece of text saying that a file attachment has be moved somewhere else and how to get to it. Last thing: to delete the shortcut, do you use "Kill" or some other easier way? Thank you again. That is very kind of you. >-----Original Message----- >Hi, >You cannot add a .lnk file this way (using olByReference) >At least it did not work for me either. > >The way I got around it was to create my own .lnk (shortcut file) >and then attach it to the email and then delete the .lnk file itself. >So in essence, I save the attachment to the users harddrive, create a >temporary shortcut to it, add the .lnk file as an attachment to the email >then delete the original attachment and the .lnk file I just created. > >I also add a hyperlink to the file in the body of the email itself because >depending >on the security setting Outlook will block the .lnk attachment anyway. > >There's way too much code to post here so if you're interested, let me know >and I >can send you the entire VB app if you want or just the relevant portions of >code and you can >try to adapt it to your needs. > >-- >HTH >Daniel Artuso, Access MVP > >"Jac Tremblay" <jact@mediom.qc.ca> wrote in message >news:048a01c33cab$e6dbbb20$a001280a@phx.gbl... >> I am programing an application with Outlook 2000 VBA. >> >> When I find a message that is very big, I check if it >> contains some attachments. If it does, I open the message >> and save the attachments to disk. I then try to modify the >> message body to add a "By Reference" link to this file. I >> get the following message (translated from French): >> >> "The attachments links are not taken care of by the >> Microsoft Outlook Internet support". >> >> Is there a simple solution to this problem? A way to go >> round? >> >> Thank you. >> >> Another thing: yesterday, I posted this same message on >> the Newsgroup and I do not see it this morning? Is the >> problem with me or what? >> >> Thanks again. > > >. > |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi,
Have a look here for code to create a shortcut. I modified it to suit my puposes but this will give you the basics. http://www.mvps.org/vbnet/code/shel...ortcutcheat.htm Adding a hyperlink in the body is not the same as adding a .lnk file as an attachment. I do this by appending it to the end of the email in the format: strTrailer = "<file://" & FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & objAttachment.DisplayName & ">" which works out to: file://PathToFile Here is a snippet of code: 'does it have attachments? If mMailItem.Attachments.Count > 0 Then For j = mMailItem.Attachments.Count To 1 Step -1 Set objAttachment = mMailItem.Attachments.Item(j) 'we have to make sure we have the attachment that matches the checked item 'because we could have more than one attachment per email,also ignore lnk files If Trim$(objAttachment.DisplayName) = Trim$(lstAttachments.ListItems.Item(i)) _ And Right(objAttachment.DisplayName, 3) <> "lnk" Then 'check to see if it has an extension, if not display a message that 'its not really a file If HasExt(Trim$(objAttachment.DisplayName)) = False Then MsgBox objAttachment.DisplayName & _ " could not be processed" GoTo NoExt End If 'here we create a folder based on the sender name. check to see if folder exists If FileOrDirExists(, FolderView1.SelectedNode.path & "\" & mMailItem.SenderName) = False Then CreateDir FolderView1.SelectedNode.path & "\" & mMailItem.SenderName End If 'check to see if file exists, if it does, append the date If FileOrDirExists(FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & objAttachment.DisplayName) = False Then objAttachment.SaveAsFile FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & objAttachment.DisplayName Else 'first save file to C: objAttachment.SaveAsFile "C:\" & objAttachment.DisplayName 'now move and rename strTemp = ReplaceChar(CStr(Now), "-", "/") strTemp = ReplaceChar(strTemp, "-", ":") MoveFile "C:\" & objAttachment.DisplayName, FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & strTemp & " " & objAttachment.DisplayName End If 'add our link to the attachment to the email 'but we have to check to see if we've already added the blurb If InStr(1, mMailItem.Body, strBlurb, vbTextCompare) = 0 Then strTrailer = strBlurb & "<file://" & FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & objAttachment.DisplayName & ">" & vbCrLf & vbCrLf Else strTrailer = "<file://" & FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & objAttachment.DisplayName & ">" & vbCrLf & vbCrLf End If mMailItem.Body = mMailItem.Body & strTrailer objAttachment.Delete 'create the link strLinkPath = CreateLink(objAttachment.DisplayName, Me.FolderView1.SelectedNode.path & "\" & mMailItem.SenderName) If strLinkPath = "" Then MsgBox objAttachment.DisplayName & _ " could not be processed" On Error Resume Next Kill FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & objAttachment.DisplayName Kill "C:\" & objAttachment.DisplayName Err.Clear On Error GoTo move_err GoTo NoExt End If mMailItem.Attachments.Add strLinkPath mMailItem.Save 'now delete the .link file Kill strLinkPath End If HTH Daniel Artuso, Access MVP "Jac Tremblay" <jact@mediom.qc.ca> wrote in message news:08dc01c33f0a$df3485d0$a301280a@phx.gbl... > Mr. Daniel, > > That's exactly the simplest solution I thought of to > circumvent that limitation of Outlook. The only part of > the code I would need is the one that creates the shortcut > of the file. This is a windows function... Do I have to > use a FileSystemObject as the one we use to ckeck if a > folder or a file exist? I sure will check it out. > > The rest of the code a kind of straight forward. But I > still have a couple of questions... > > You say that you also add a hyperlink to the file in the > body of the message. But isn't that just the same as > adding a file (an attachment) with the option > olByReference? I never saw the Ctrl-k option available in > a mail message (as it is in Word, Excel, etc.)? How do you > do that? I thought I would simply add a piece of text > saying that a file attachment has be moved somewhere else > and how to get to it. > > Last thing: to delete the shortcut, do you use "Kill" or > some other easier way? > > Thank you again. That is very kind of you. > > >-----Original Message----- > >Hi, > >You cannot add a .lnk file this way (using olByReference) > >At least it did not work for me either. > > > >The way I got around it was to create my own .lnk > (shortcut file) > >and then attach it to the email and then delete the .lnk > file itself. > >So in essence, I save the attachment to the users > harddrive, create a > >temporary shortcut to it, add the .lnk file as an > attachment to the email > >then delete the original attachment and the .lnk file I > just created. > > > >I also add a hyperlink to the file in the body of the > email itself because > >depending > >on the security setting Outlook will block the .lnk > attachment anyway. > > > >There's way too much code to post here so if you're > interested, let me know > >and I > >can send you the entire VB app if you want or just the > relevant portions of > >code and you can > >try to adapt it to your needs. > > > >-- > >HTH > >Daniel Artuso, Access MVP > > > >"Jac Tremblay" <jact@mediom.qc.ca> wrote in message > >news:048a01c33cab$e6dbbb20$a001280a@phx.gbl... > >> I am programing an application with Outlook 2000 VBA. > >> > >> When I find a message that is very big, I check if it > >> contains some attachments. If it does, I open the > message > >> and save the attachments to disk. I then try to modify > the > >> message body to add a "By Reference" link to this file. > I > >> get the following message (translated from French): > >> > >> "The attachments links are not taken care of by the > >> Microsoft Outlook Internet support". > >> > >> Is there a simple solution to this problem? A way to go > >> round? > >> > >> Thank you. > >> > >> Another thing: yesterday, I posted this same message on > >> the Newsgroup and I do not see it this morning? Is the > >> problem with me or what? > >> > >> Thanks again. > > > > > >. > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Mr. Artuso,
I've checked your code and your comments and found the answer to my problem. The main thing to know if one wants to add a link to a file to a hard drive is to use the "File://" concatenated with the valid path and file name. If either component contains spaces, one must enclose the whole thing between double quotes. Here is the line of code that does it: msgMessage.Body = msgMessage.Body & vbCrLf & _ """" & "File:\\" & strPath & strFileName & """" It is as simple as that... Thank you again for your precious time. Jac Tremblay >-----Original Message----- >Hi, >Have a look here for code to create a shortcut. >I modified it to suit my puposes but this will give you the basics. >http://www.mvps.org/vbnet/code/shel...ortcutcheat.htm > >Adding a hyperlink in the body is not the same as adding a .lnk >file as an attachment. >I do this by appending it to the end of the email in the format: > >strTrailer = "<file://" & FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName & "\" & objAttachment.DisplayName & ">" >which works out to: >file://PathToFile > >Here is a snippet of code: > >'does it have attachments? > If mMailItem.Attachments.Count > 0 Then > For j = mMailItem.Attachments.Count To 1 Step -1 > > Set objAttachment = mMailItem.Attachments.Item(j) > 'we have to make sure we have the attachment that matches >the checked item > 'because we could have more than one attachment per >email,also ignore lnk files > If Trim$(objAttachment.DisplayName) = >Trim$(lstAttachments.ListItems.Item(i)) _ > And Right (objAttachment.DisplayName, 3) <> "lnk" Then > > 'check to see if it has an extension, if not display >a message that > 'its not really a file > If HasExt (Trim$(objAttachment.DisplayName)) = False >Then > MsgBox objAttachment.DisplayName & _ > " could not be processed" > GoTo NoExt > End If > > 'here we create a folder based on the sender name. >check to see if folder exists > If FileOrDirExists(, FolderView1.SelectedNode.path & >"\" & mMailItem.SenderName) = False Then > CreateDir FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName > End If > 'check to see if file exists, if it does, append the >date > If FileOrDirExists (FolderView1.SelectedNode.path & >"\" & mMailItem.SenderName & "\" & objAttachment.DisplayName) = False Then > > objAttachment.SaveAsFile >FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & >objAttachment.DisplayName > Else > 'first save file to C: > objAttachment.SaveAsFile "C:\" & >objAttachment.DisplayName > 'now move and rename > strTemp = ReplaceChar(CStr (Now), "-", "/") > strTemp = ReplaceChar (strTemp, "-", ":") > MoveFile "C:\" & objAttachment.DisplayName, >FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & strTemp & >" " & objAttachment.DisplayName > End If > 'add our link to the attachment to the email > 'but we have to check to see if we've already added >the blurb > If InStr(1, mMailItem.Body, strBlurb, vbTextCompare) >= 0 Then > strTrailer = strBlurb & "<file://" & >FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & >objAttachment.DisplayName & ">" & vbCrLf & vbCrLf > Else > strTrailer = "<file://" & >FolderView1.SelectedNode.path & "\" & mMailItem.SenderName & "\" & >objAttachment.DisplayName & ">" & vbCrLf & vbCrLf > End If > mMailItem.Body = mMailItem.Body & strTrailer > objAttachment.Delete > 'create the link > strLinkPath = CreateLink (objAttachment.DisplayName, >Me.FolderView1.SelectedNode.path & "\" & mMailItem.SenderName) > If strLinkPath = "" Then > MsgBox objAttachment.DisplayName & _ > " could not be processed" > On Error Resume Next > Kill FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName & "\" & objAttachment.DisplayName > Kill "C:\" & objAttachment.DisplayName > Err.Clear > On Error GoTo move_err > GoTo NoExt > End If > > mMailItem.Attachments.Add strLinkPath > mMailItem.Save > 'now delete the .link file > Kill strLinkPath > End If > >HTH >Daniel Artuso, Access MVP > >"Jac Tremblay" <jact@mediom.qc.ca> wrote in message >news:08dc01c33f0a$df3485d0$a301280a@phx.gbl... >> Mr. Daniel, >> >> That's exactly the simplest solution I thought of to >> circumvent that limitation of Outlook. The only part of >> the code I would need is the one that creates the shortcut >> of the file. This is a windows function... Do I have to >> use a FileSystemObject as the one we use to ckeck if a >> folder or a file exist? I sure will check it out. >> >> The rest of the code a kind of straight forward. But I >> still have a couple of questions... >> >> You say that you also add a hyperlink to the file in the >> body of the message. But isn't that just the same as >> adding a file (an attachment) with the option >> olByReference? I never saw the Ctrl-k option available in >> a mail message (as it is in Word, Excel, etc.)? How do you >> do that? I thought I would simply add a piece of text >> saying that a file attachment has be moved somewhere else >> and how to get to it. >> >> Last thing: to delete the shortcut, do you use "Kill" or >> some other easier way? >> >> Thank you again. That is very kind of you. >> >> >-----Original Message----- >> >Hi, >> >You cannot add a .lnk file this way (using olByReference) >> >At least it did not work for me either. >> > >> >The way I got around it was to create my own .lnk >> (shortcut file) >> >and then attach it to the email and then delete the .lnk >> file itself. >> >So in essence, I save the attachment to the users >> harddrive, create a >> >temporary shortcut to it, add the .lnk file as an >> attachment to the email >> >then delete the original attachment and the .lnk file I >> just created. >> > >> >I also add a hyperlink to the file in the body of the >> email itself because >> >depending >> >on the security setting Outlook will block the .lnk >> attachment anyway. >> > >> >There's way too much code to post here so if you're >> interested, let me know >> >and I >> >can send you the entire VB app if you want or just the >> relevant portions of >> >code and you can >> >try to adapt it to your needs. >> > >> >-- >> >HTH >> >Daniel Artuso, Access MVP >> > >> >"Jac Tremblay" <jact@mediom.qc.ca> wrote in message >> >news:048a01c33cab$e6dbbb20$a001280a@phx.gbl... >> >> I am programing an application with Outlook 2000 VBA. >> >> >> >> When I find a message that is very big, I check if it >> >> contains some attachments. If it does, I open the >> message >> >> and save the attachments to disk. I then try to modify >> the >> >> message body to add a "By Reference" link to this file. >> I >> >> get the following message (translated from French): >> >> >> >> "The attachments links are not taken care of by the >> >> Microsoft Outlook Internet support". >> >> >> >> Is there a simple solution to this problem? A way to go >> >> round? >> >> >> >> Thank you. >> >> >> >> Another thing: yesterday, I posted this same message on >> >> the Newsgroup and I do not see it this morning? Is the >> >> problem with me or what? >> >> >> >> Thanks again. >> > >> > >> >. >> > > > >. > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Actually, the code should be:
msgMessage.Body = msgMessage.Body & vbCrLf & _ """" & "<" & "File://" & strPath & strFileName & ">" & """" Thanks again. >-----Original Message----- >Mr. Artuso, > >I've checked your code and your comments and found the >answer to my problem. The main thing to know if one wants >to add a link to a file to a hard drive is to use >the "File://" concatenated with the valid path and file >name. If either component contains spaces, one must >enclose the whole thing between double quotes. Here is the >line of code that does it: > > msgMessage.Body = msgMessage.Body & vbCrLf & _ > """" & "File:\\" & strPath & strFileName & """" > >It is as simple as that... > >Thank you again for your precious time. > >Jac Tremblay > >>-----Original Message----- >>Hi, >>Have a look here for code to create a shortcut. >>I modified it to suit my puposes but this will give you >the basics. >>http://www.mvps.org/vbnet/code/shel...ortcutcheat.htm >> >>Adding a hyperlink in the body is not the same as adding >a .lnk >>file as an attachment. >>I do this by appending it to the end of the email in the >format: >> >>strTrailer = "<file://" & FolderView1.SelectedNode.path >& "\" & >>mMailItem.SenderName & "\" & objAttachment.DisplayName >& ">" >>which works out to: >>file://PathToFile >> >>Here is a snippet of code: >> >>'does it have attachments? >> If mMailItem.Attachments.Count > 0 Then >> For j = mMailItem.Attachments.Count To 1 >Step -1 >> >> Set objAttachment = >mMailItem.Attachments.Item(j) >> 'we have to make sure we have the >attachment that matches >>the checked item >> 'because we could have more than one >attachment per >>email,also ignore lnk files >> If Trim$(objAttachment.DisplayName) = >>Trim$(lstAttachments.ListItems.Item(i)) _ >> And Right >(objAttachment.DisplayName, 3) <> "lnk" Then >> >> 'check to see if it has an >extension, if not display >>a message that >> 'its not really a file >> If HasExt >(Trim$(objAttachment.DisplayName)) = False >>Then >> MsgBox >objAttachment.DisplayName & _ >> " could not be processed" >> GoTo NoExt >> End If >> >> 'here we create a folder based on >the sender name. >>check to see if folder exists >> If FileOrDirExists(, >FolderView1.SelectedNode.path & >>"\" & mMailItem.SenderName) = False Then >> CreateDir >FolderView1.SelectedNode.path & "\" & >>mMailItem.SenderName >> End If >> 'check to see if file exists, if >it does, append the >>date >> If FileOrDirExists >(FolderView1.SelectedNode.path & >>"\" & mMailItem.SenderName & "\" & >objAttachment.DisplayName) = False Then >> >> objAttachment.SaveAsFile >>FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName & "\" & >>objAttachment.DisplayName >> Else >> 'first save file to C: >> >objAttachment.SaveAsFile "C:\" & >>objAttachment.DisplayName >> 'now move and rename >> strTemp = ReplaceChar(CStr >(Now), "-", "/") >> strTemp = ReplaceChar >(strTemp, "-", ":") >> MoveFile "C:\" & >objAttachment.DisplayName, >>FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName & "\" & strTemp & >>" " & objAttachment.DisplayName >> End If >> 'add our link to the attachment >to the email >> 'but we have to check to see if >we've already added >>the blurb >> If InStr(1, mMailItem.Body, >strBlurb, vbTextCompare) >>= 0 Then >> strTrailer = strBlurb >& "<file://" & >>FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName & "\" & >>objAttachment.DisplayName & ">" & vbCrLf & vbCrLf >> Else >> strTrailer = "<file://" & >>FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName & "\" & >>objAttachment.DisplayName & ">" & vbCrLf & vbCrLf >> End If >> mMailItem.Body = mMailItem.Body & >strTrailer >> objAttachment.Delete >> 'create the link >> strLinkPath = CreateLink >(objAttachment.DisplayName, >>Me.FolderView1.SelectedNode.path & "\" & >mMailItem.SenderName) >> If strLinkPath = "" Then >> MsgBox >objAttachment.DisplayName & _ >> " could not be processed" >> On Error Resume Next >> Kill >FolderView1.SelectedNode.path & "\" & >>mMailItem.SenderName & "\" & objAttachment.DisplayName >> Kill "C:\" & >objAttachment.DisplayName >> Err.Clear >> On Error GoTo move_err >> GoTo NoExt >> End If >> >> mMailItem.Attachments.Add >strLinkPath >> mMailItem.Save >> 'now delete the .link file >> Kill strLinkPath >> End If >> >>HTH >>Daniel Artuso, Access MVP >> >>"Jac Tremblay" <jact@mediom.qc.ca> wrote in message >>news:08dc01c33f0a$df3485d0$a301280a@phx.gbl... >>> Mr. Daniel, >>> >>> That's exactly the simplest solution I thought of to >>> circumvent that limitation of Outlook. The only part of >>> the code I would need is the one that creates the >shortcut >>> of the file. This is a windows function... Do I have to >>> use a FileSystemObject as the one we use to ckeck if a >>> folder or a file exist? I sure will check it out. >>> >>> The rest of the code a kind of straight forward. But I >>> still have a couple of questions... >>> >>> You say that you also add a hyperlink to the file in the >>> body of the message. But isn't that just the same as >>> adding a file (an attachment) with the option >>> olByReference? I never saw the Ctrl-k option available >in >>> a mail message (as it is in Word, Excel, etc.)? How do >you >>> do that? I thought I would simply add a piece of text >>> saying that a file attachment has be moved somewhere >else >>> and how to get to it. >>> >>> Last thing: to delete the shortcut, do you use "Kill" or >>> some other easier way? >>> >>> Thank you again. That is very kind of you. >>> >>> >-----Original Message----- >>> >Hi, >>> >You cannot add a .lnk file this way (using >olByReference) >>> >At least it did not work for me either. >>> > >>> >The way I got around it was to create my own .lnk >>> (shortcut file) >>> >and then attach it to the email and then delete >the .lnk >>> file itself. >>> >So in essence, I save the attachment to the users >>> harddrive, create a >>> >temporary shortcut to it, add the .lnk file as an >>> attachment to the email >>> >then delete the original attachment and the .lnk file I >>> just created. >>> > >>> >I also add a hyperlink to the file in the body of the >>> email itself because >>> >depending >>> >on the security setting Outlook will block the .lnk >>> attachment anyway. >>> > >>> >There's way too much code to post here so if you're >>> interested, let me know >>> >and I >>> >can send you the entire VB app if you want or just the >>> relevant portions of >>> >code and you can >>> >try to adapt it to your needs. >>> > >>> >-- >>> >HTH >>> >Daniel Artuso, Access MVP >>> > >>> >"Jac Tremblay" <jact@mediom.qc.ca> wrote in message >>> >news:048a01c33cab$e6dbbb20$a001280a@phx.gbl... >>> >> I am programing an application with Outlook 2000 VBA. >>> >> >>> >> When I find a message that is very big, I check if it >>> >> contains some attachments. If it does, I open the >>> message >>> >> and save the attachments to disk. I then try to >modify >>> the >>> >> message body to add a "By Reference" link to this >file. >>> I >>> >> get the following message (translated from French): >>> >> >>> >> "The attachments links are not taken care of by the >>> >> Microsoft Outlook Internet support". >>> >> >>> >> Is there a simple solution to this problem? A way to >go >>> >> round? >>> >> >>> >> Thank you. >>> >> >>> >> Another thing: yesterday, I posted this same message >on >>> >> the Newsgroup and I do not see it this morning? Is >the >>> >> problem with me or what? >>> >> >>> >> Thanks again. >>> > >>> > >>> >. >>> > >> >> >>. >> >. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

