Solved

How do you put a variable in a  shell command line?

Posted on 2007-11-28
3
180 Views
Last Modified: 2010-04-23
Shell("C:\Program Files\Microsoft Office\Office11\Outlook.exe /c ipm.note /m mailto:name@comcast.net&subject=Retrofits%21&body=txtRetrofitPartNumber.text")

I have the above command line in a Visual Basic Button_Click event.  When I click the button a pre-addressed, pre-formatted new e-mail message pops up. To: name@comcast.net, Subject: Retrofits.  This is what I want so far.  In the body I have the literal txtRetrofitPartNumber.text. n my program that is a variable.  It is a textbox that the text will change from time to time.  I want my e-mail to have the text that was typed into txtretrofitPartNumber.text not the literal "txtRetrofitPartNumber.text"  Any ideas how to do that?
0
Comment
Question by:markleszczynski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 20369712
Shell("C:\Program Files\Microsoft Office\Office11\Outlook.exe /c ipm.note /m mailto:name@comcast.net&subject=Retrofits%21&body=" & txtRetrofitPartNumber.text)

That was the simple answer.  The complete answer is that Shell is included for compatibility with VB6, and you should really move on to using System.Diagnostics.Process()  (or just Process() ) instead.  Then build the string like I show above.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 20369721
Shell("C:\Program Files\Microsoft Office\Office11\Outlook.exe /c ipm.note /m mailto:name@comcast.net&subject=Retrofits%21&body="+ txtRetrofitPartNumber.Text)
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20369751
notice your text should be very short and simple. Will be better if you use UrlEnconding to avoid invalid characters in body text:

Shell("C:\Program Files\Microsoft Office\Office11\Outlook.exe /c ipm.note /m mailto:name@comcast.net&subject=Retrofits%21&body=" & _
System.Web.HttpUtility.UrlEncode(txtRetrofitPartNumber.Text))
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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