Wrox Programmer Forums
|
.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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 18th, 2008, 03:33 PM
Friend of Wrox
 
Join Date: Mar 2007
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?
 
Old February 19th, 2008, 05:57 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
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 -/
 
Old February 19th, 2008, 09:53 AM
Friend of Wrox
 
Join Date: Mar 2007
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)
 
Old February 19th, 2008, 09:58 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
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 -/
 
Old February 19th, 2008, 03:45 PM
Friend of Wrox
 
Join Date: Mar 2007
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.
 
Old February 20th, 2008, 04:16 PM
Friend of Wrox
 
Join Date: Mar 2007
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)
 
Old October 26th, 2008, 10:53 PM
Registered User
 
Join Date: Oct 2008
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






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





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