Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 April 17th, 2008, 10:11 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default Defining a process

Can someone tell me what the syntax is for defining a process. Below code (calls outlook with an attachment)is taken from a current windows application, but I cannot determine what an equivalent would be in asp. Thank you.

Code:
Dim prc As New Process
prc.StartInfo = New ProcessStartInfo("outlook.exe", "/a " + ControlChars.Quote & myFilePath & ControlChars.Quote)
prc.Start()
 
Old April 17th, 2008, 11:35 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I figured it out, here is the code for displaying a Crystal Report and having an "Email' button that will call outlook with the document as an attachment:


Code:
Protected Sub EmailButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EmailButton.Click

        Dim myFileName As String = String.Format("\{0:yyyyMMdd_HHmmss}.doc", Date.Now)
        Dim myFilePath As String = "c:\windows\temp" + myFileName

        myCrystalReport.ExportToDisk(ExportFormatType.WordForWindows, myFilePath)

        Try
            Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
            myProcess.StartInfo = New Diagnostics.ProcessStartInfo("outlook.exe", "/a " + ControlChars.Quote & myFilePath & ControlChars.Quote)
            myProcess.Start()
        Catch ex As Exception
            ErrorString = ex.ToString
            ASPNET_MsgBox("An error has occurred sending email: " + vbCrLf + ErrorString)
        End Try

    End Sub


 
Old April 17th, 2008, 11:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. Just a question about your code. (to clarify)

This code start the proccess in the client machine or in the server? Since the code is executing in the server, did you try it out in a web enviroment? (I mean, running from another PC?) Also, what happens if the client doesn't have outlook?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old April 17th, 2008, 11:56 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Ouch.... I think this code will earn you the "works on my machine" award from Gonzalo's signature....

As Gonzalo pointed out, this code runs on the server. It's not at all recommended to have web applications run client applications like this. What happens when you have 100 concurrent users? You'll end up with 100 instances of Outlook.

Also, who's going to enter the To address and press the Send button?

Are you running this on your local machine? If so, just for fun, try accessing the web site from a different machine. That will give you a clearer idea of what the server is, and what the client.

Finally, look at the System.Net.Mail namespace. It has all the functionality you need to send e-mail; with attachments as the following simple example demonstrates:
Code:
MailMessage myMessage = new MailMessage();
myMessage.From = new MailAddress("you@yourprovider.com");
myMessage.To.Add(new MailAddress("them@theirprovider.com"));
myMessage.Attachments.Add(new Attachment(@"D:\SomeFile.txt"));
new SmtpClient("Your.Mail.Server").Send(myMessage);
Hope this helps,

Imar



---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old April 23rd, 2008, 06:50 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

The code runs on the server. This is an intranet app and all the clients have outlook. The max user will be about 10. The reason for calling Outlook is to have the user enter the distribution list and any comments or notes as this may vary.

 
Old April 23rd, 2008, 07:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This code runs on the server so whether the client has Outlook or not is irrelevant. This code never reaches the client....

If you insist to use Outlook on the client (not recommended), you need to look into client side automation of Outlook using VBScript / JavaScript or other means like ActiceX

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
process.startinfo opens new instance of process Anypond General .NET 0 August 28th, 2008 05:35 AM
help with defining in the database derrida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 April 14th, 2007 03:17 AM
Defining Methods for a WebService ename .NET Web Services 0 November 21st, 2006 12:01 PM
Defining the Variables. dpkbahuguna Beginning VB 6 2 November 1st, 2006 12:40 PM
Defining ID attributes Fiddleman XML 1 June 30th, 2004 09:41 AM





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