Bring up outlook client from ASP.Net

R

Raymond Du

Hi,

I have a ASP.Net button in a webform. What I like to do, if this button is
clicked, the page should connect to a SQL server run some stored procedure,
then bring up user's MS Outlook client and fill in the mail to address,
subject and body using the dataset returned by stored procedure. I know how
to connect to SQL and get dataset back, I don't know how to bring up
Outllook on client side and fill in mailto, subject and body.

BTW, All our user computers are configured to use MS Outlook as default
email agent .

TIA
 
M

MWells

Raymond, if you're just trying to fill in the To/Cc/Subject, there might be
an easier way.

When the user clicks the button, do your database query and construct a
mailto Url, something in the following format;

mailto:[ your To addresses ]&Cc=[ Any Cc addresses ]&Subject=[ The Subject ]

e.g....

mailto:[email protected]&[email protected]&Subject=Hey how's it going

If you then do a Response.Redirect to this Url, I expect that IE will create
a new mail message using your defailt email client nicely.

The effect should be, user clicks the button and the email form appears...
essentially no other complications.

You will probably need to Server.UrlEncode the actual data that you put in
place of the [bracketed] text, as in;

string szUrl, szToAddresses, szCcAddresses, szSubject;

// do your db query, set the To, Cc, and Subject vars

// create the Url
szUrl = String.Format (
"mailto:{0}&Cc={1}&Subject={2}",
Server.UrlEncode (szToAddresses),
Server.UrlEncode (szCcAddresses),
Server.UrlEncode (szSubject)
);

Trace.Write ("Mailto Url: " + szUrl); // for debugging

// force the browser to process the new Url
Response.Redirect (szUrl);


/// M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top