Hi :)
I want to click on a button and open the mail
box so i can put message and send it, how
can i do that ?
Thanks.
Hi :)
I want to click on a button and open the mail
box so i can put message and send it, how
can i do that ?
Thanks.
Jump to PostIf by mail box you mean an email application like outlook, you can use the Process class from System.Diagnostics.
System.Diagnostics.Process.Start( "outlook.exe" );
Jump to PostI'm not sure you can do that with outlook, but I'd start by seeing if there's a command line switch I could use. Something like
System.Diagnostics.Process.Start( "outlook.exe /newmessage" );
You're probably asking too much for a simple solution and the best way to solve the problem would …
Jump to PostYou might want to try the HTML mailto syntax.
For example: <a href="mailto:email@test.com?body=I am having trouble finding information on... ">email me></a>
Clicking on the above link will open your default email handler with message already started in Body. (Check this page for more examples
If by mail box you mean an email application like outlook, you can use the Process class from System.Diagnostics.
System.Diagnostics.Process.Start( "outlook.exe" );
Hi :)
Thanks for the answer, but i want it to directly go
to a new message and automaticly insert an email
that i choose and let me write a message and send it.
How can i do that ?
Thanks.
I'm not sure you can do that with outlook, but I'd start by seeing if there's a command line switch I could use. Something like
System.Diagnostics.Process.Start( "outlook.exe /newmessage" );
You're probably asking too much for a simple solution and the best way to solve the problem would be to write your own mail handler instead of calling an existing one. :(
You might want to try the HTML mailto syntax.
For example: <a href="mailto:email@test.com?body=I am having trouble finding information on... ">email me></a>
Clicking on the above link will open your default email handler with message already started in Body. (Check this page for more examples http://www.ianr.unl.edu/internet/mailto.html)
Now you have to see how to integrate HTML into your application.
Good luck.
I give u a brief peace of code
First u must include
using System.Net.Mail;
//Initialize an SMTP client
SmtpClient objSmtpClient = new SmtpClient();
MailMessage objMail = new MailMessage();
// Precise the mail adress sender and reciever
MailAdress oSenderAdress = new MailAdress("dsd@dsdd.fd");
MailAdress oRecieverAdress = new MailAdress("sdsd@dsdsd.fd");
//Parameter the objMail
objMail.From = oSenderAdress;
objMail.To = oRecieverAdress;
//To send the email u can use the method
try{
objSmtpClient.send(objMail);
}
catch(Exception caught)
{ Response.Redirect("http://www.yourWebSite/ErrorPage.asp");
}
I have actually seen what 1qaz2wsx7 is talking about. It's actually pretty cool. I first saw it at work when a end user needed some help. She was using a Access DB that on one of the forms would actually open up Lotus Notes and fill in the Recipient, Subject and Body.
On a windows machines it uses the default email program that I think can be set int Internet Options -> Programs-> Email setting.
My 2 Cents
WOw this is an old thread, but it is possible to launch the default email program with a new message window wih this code:
System.Diagnostics.Process.Start("mailto:foo@bar.info");
the when Windows sees the mailto protocol it opens the associated program. The program will open a new message page only (Well that's what Windows Mail and Outlook did on my Vista system). You can change the mailto arguments. See: http://www.ianr.unl.edu/internet/mailto.html
you can use the mailto: syntax to fill in the email in its entirety. It's throughly documented in the RFC822 standard...
Hi :)
I want to click on a button and open the mail
box so i can put message and send it, how
can i do that ?Thanks.
hi
hw r u? i m fine well. im studying here.what r u doing?
Please use the following code.
and add .dll's
Interop.Outlook.dll
Interop.Microsoft.Office.Core.dll
Office.dll
protected void Button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem objMail;
objMail = (Microsoft.Office.Interop.Outlook.MailItem)objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
objMail.To = "s731061@emirates.com;
objMail.Subject = "Testmail";
objMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
objMail.Body = "Welcome to Outlook";
objMail.Display(Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML);
}
sabeer pasha.
Please use the following code.
and add .dll's
Interop.Outlook.dll
Interop.Microsoft.Office.Core.dll
Office.dll
protected void Button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem objMail;
objMail = (Microsoft.Office.Interop.Outlook.MailItem)objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
objMail.To = "s731061@emirates.com;
objMail.Subject = "Testmail";
objMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
objMail.Body = "Welcome to Outlook";
objMail.Display(Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML);
}
sabeer pasha.
Thanks SabeerPasha, it worked for me.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.