Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now