Solved

Add link to e-mail from Microsoft Access to network folders

Posted on 2015-02-20
8
159 Views
Last Modified: 2015-02-23
Hi,

I have an access database that is used for component tests, and once the tests are complete I want to send an e-mail from Access to notify a user that the test report is now available at a network location.

The location name is:-

\\bpl-sp\Inspection & Testing\Hardness Reports

No matter what I try I cannot make it get past the \\bpl-sp\Inspection part.

How can I tell access to send the full link in the e-mail?

Thanks

Les Shepherd
0
Comment
Question by:LJShepherd
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 40621284
We can't tell why you are having a problem.  A string is a string.  You may not be delimiting it correctly.  Please post your code.
0
 

Author Comment

by:LJShepherd
ID: 40621295
Hi Pat,

Here is the code I am using.

I can generate the e-mail, but can't get the link to work.

Thanks

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

strNewPath = "\\bpl-sp\Testing & Inspection\Hardness Reports\" & "SO" & Me.BPLSO & "-HR" & Me.POrderNo & ".pdf"



With MailOutLook
    .To = "it@beckprosper.com"
   
   
    .Subject = "Hardness Test " & "SO" & Me.BPLSO & "-HR" & Me.POrderNo
   
    .Body = "The Hardness Tests for " & "SO" & Me.BPLSO & "-HR" & Me.POrderNo & " have been completed and the report is now ready for inclusion in your document pack and can also be added to the Portal." & vbNewLine & vbNewLine & "The document can be found at this location " & vbNewLine & vbNewLine & strNewPath
   
    .Send
   
End With
 EditMessage = True
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 40621490
How can I tell access to send the full link in the e-mail?
if you want the link to be clickable then you need an .HTMLBody and not a .Body

Dim TheHTML as string
TheHTML = "<p>The Hardness Tests for " 
TheHTML = TheHTML & "<a href = " & chr(34) & strNewPath & chr(34) & ">"
TheHTML = TheHTML & "SO" & Me.BPLSO & "-HR" & Me.POrderNo  & "</a>"
TheHTML = TheHTML & " have been completed and the report is now ready for inclusion in your document pack and can also be added to the Portal. <br><br></p>"

    .HTMLBody = TheHTML
Have a look at how to open Outlook in this article
http://www.experts-exchange.com/Programming/Microsoft_Development/A_17466-Properly-open-Outlook-as-an-Application-object-in-VBA.html

On Error Resume Next is an unhappy thing.
There are better ways to deal with Outlook being open or closed at run-time
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 36

Expert Comment

by:PatHartman
ID: 40621774
I don't see any missing delimiters.  Could any of your variables contain the " character?  If so, you can use the single quote to delimit the string.  If the string could contain either, then use the double quote but add code to "escape" the embedded double quote by changing embedded " to "".
0
 

Author Comment

by:LJShepherd
ID: 40622276
Hi Pat,

Sorry, but I don't quite understand your comment.

If my path is "\\bpl-sp\Testing & Inspection\Hardness Reports\" & "SO" & Me.BPLSO & "-HR" & Me.POrderNo & ".pdf"

Where do I put the single quote please?

I don't believe any of my variables contain the " character.

Thanks

Les
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40622345
I'm not sure about @Pat's comment either
Still
No matter what I try I cannot make it get past the \\bpl-sp\Inspection part.

To get a clickable link, you'll still need .HTMLBody and the string to be valid HTML
Build it up in chunks the way I've coded it.
You can drop a breakpoint on each line, or throw a MsgBox TheHTML between each line and debug in bits to see where the grief lies.

I can generate the e-mail, but can't get the link to work.
.Body is never going to permit a clickable link.
.Body is PlainText
A clickable link needs a .HTMLBody
0
 
LVL 84
ID: 40622348
Perhaps:

strNewPath = "\\bpl-sp\Testing & Inspection\Hardness Reports\SO" & Me.BPLSO & "-HR" & Me.POrderNo & ".pdf"

Also, here's an article about using Outlook to automate things like this:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_4316-Automate-Outlook-in-VBA-with-the-OutlookCreateItem-Class.html

It's got full source code and shows exactly how to create your objects, emails, etc.
0
 

Author Closing Comment

by:LJShepherd
ID: 40625909
Thanks for your input folks. I looked at the problem and messed around with the code that Nick67 provided and came up with the answer.

Cheers

Les Shepherd
0

Featured Post

Technology Partners: 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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

679 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