Solved

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

Posted on 2007-11-28
3
182 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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