Solved

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

Posted on 2015-02-20
8
155 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 34

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
 
LVL 34

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now