Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 18th, 2008, 03:33 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default [Resolved] Open Outlook application

I'm trying to call Outlook with an attachment:

This works fine:

Code:
Shell("C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE")
When I try with an attachment, it tells me that file is not found even if the file is there:

Code:
Dim myOutlookString As String = "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE""" + "/a " + """C:\mycrystalreport.pdf"
Shell(myOutlookString)
Any ideas?
Reply With Quote
  #2 (permalink)  
Old February 19th, 2008, 05:57 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You don't appear to have a space between the end of OUTLOOK.EXE and the /a symbol.

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old February 19th, 2008, 09:53 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I tried this as well (space bewteen .exe and /a)and getting error:

An error has been encountered trying to access Outlook.
System.IO.FileNotFoundException: File not found.


It might sound silly, but the file exists in c:\.

Code:
Dim myOutlookString As String = "C:\Program Files\Microsoft Office\Office12\Outlook.exe""" + " /a " + """C:\mycrystalreport.pdf"
Shell(myOutlookString)
Reply With Quote
  #4 (permalink)  
Old February 19th, 2008, 09:58 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You also appear to have a strange number of " symbols in there. Try the following:

Dim myOutlookString As String = """C:\Program Files\Microsoft Office\Office12\Outlook.exe"" /a ""C:\mycrystalreport.pdf"""
Shell(myOutlookString)

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #5 (permalink)  
Old February 19th, 2008, 03:45 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

That really did the trick. Thank you.

By the way,

1. Is there a way to pogramatically attach a crystal report to outlook instead of exporting to a folder and then attach?

2. Or is there a way where I programatically can export the crystal report to a file?

My (vb) program produces a crystal report and I would like to click a button and then open outlook with attachment.
Reply With Quote
  #6 (permalink)  
Old February 20th, 2008, 04:16 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I figured out how to programatically create/export crystal report to a file object:

Code:
Dim myFilePath As String = "C:\Documents and Settings\" + Windows.Forms.SystemInformation.UserName + "\Local Settings\Temp" + myFileName
Dim myReport As New ReportClass
myReport = myCrystalReport
myReport.ExportToDisk(ExportFormatType.WordForWindows, myFilePath)
Now I can email ie call/open Outlook and attach the report automatically:

Code:
Dim myOutlookString As String = """C:\Program Files\Microsoft Office\Office12\Outlook.exe"" /a """ + myFilePath + """"
Shell(myOutlookString)
Reply With Quote
  #7 (permalink)  
Old October 26th, 2008, 10:53 PM
Registered User
 
Join Date: Oct 2008
Location: jakarta, , Indonesia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

"C:\Program Files\Microsoft Office\Office12\Outlook.exe""" + " /a " + """C:\mycrystalreport.pdf"

work fine to call Outlook with attachment, but is it possible to insert send to address, mail subject, mail body and CC??

Thanks

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
open text and add to outlook body mlov83 BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 0 February 16th, 2008 08:48 AM
[Resolved] [2005] Call Outlook in vb application snufse .NET Framework 2.0 1 February 12th, 2008 04:58 PM
[Resolved] [2005] Call Outlook with attachment snufse .NET Framework 2.0 4 February 12th, 2008 09:59 AM
Activate Outlook and open a specific mailfolder Mats Excel VBA 0 January 24th, 2006 09:44 AM
Open email client (like Outlook) from VB pavel Pro VB 6 1 June 7th, 2004 11:57 PM



All times are GMT -4. The time now is 12:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.