Solved

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

Posted on 2015-02-20
8
152 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now