Groups | Blog | Home
all groups > asp.net > january 2005 >

asp.net : Bring up outlook client from ASP.Net


Raymond Du
1/14/2005 10:50:12 PM
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

charmis
1/15/2005 1:06:29 PM
Hi Rayomond,

Pls check the link
http://www.outlookcode.com/d/code/formonweb.htm

regards
charmis


[quoted text, click to view]

MWells
1/15/2005 9:13:16 PM
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:bob@bobware.com&Cc=fred@bobware.com&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


[quoted text, click to view]

AddThis Social Bookmark Button