markleszczynski
asked on
How do you put a variable in a shell command line?
Shell("C:\Program Files\Microsoft Office\Office11\Outlook.ex e /c ipm.note /m mailto:name@comcast.net&su bject=Retr ofits%21&b ody=txtRet rofitPartN umber.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.tex t" Any ideas how to do that?
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.ex e /c ipm.note /m mailto:name@comcast.net&su bject=Retr ofits%21&b ody=" & _
System.Web.HttpUtility.Url Encode(txt RetrofitPa rtNumber.T ext))
Shell("C:\Program Files\Microsoft Office\Office11\Outlook.ex
System.Web.HttpUtility.Url
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