adamtrask
asked on
starting an outlook email from inside a win form in C#
Good morning,,
I created an application in C# where, at some point, the user will need to use outlook to send an email to a colleague.
The email address of the percipient as well as the body and subject matter are placed in text boxes in the win form waiting to be moved or copied to the outgoing email in Outlook.
So, basically my question is: how do I run outlook form inside a win form, select a new email copy the recipient email address and the body of text into the email and send it.
Thank you
I created an application in C# where, at some point, the user will need to use outlook to send an email to a colleague.
The email address of the percipient as well as the body and subject matter are placed in text boxes in the win form waiting to be moved or copied to the outgoing email in Outlook.
So, basically my question is: how do I run outlook form inside a win form, select a new email copy the recipient email address and the body of text into the email and send it.
Thank you
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What namespace of reference do I need to use...?
OK . I will send it once I get back to my computer
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ASKER
I should add that i am using Visual Studio 2010
ASKER
OK, I now know how to add a reference to the project.... and will be able to try your code. Thank you for your patience FarWest...
Nevermind . you are welcome and sorry for not mentioning the reference part
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both...
I couldn't respond during the weekend because I don't have access to Outlook at home. Now that I am back in the office I was able to test what I got from you and a lot of other code I found online.
Finally I was able to do what I needed with the following piece of code which I would like to share with others who might find a need for it:
private void CreateMailItem()
{
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)outlookA pp.CreateI tem(Outloo k.OlItemTy pe.olMailI tem);
mailItem.Subject = this.txtSubject.Text;
mailItem.To = txtAddress.Text;
mailItem.Body = txtBody.Text;
mailItem.Importance = Outlook.OlImportance.olImp ortanceLow ;
mailItem.Display(false);
}
Éric Moreau: Right now I don't plan to include attachments to my code, but I am sure your article will be of help at some point in the future. Thank you
Adam
I couldn't respond during the weekend because I don't have access to Outlook at home. Now that I am back in the office I was able to test what I got from you and a lot of other code I found online.
Finally I was able to do what I needed with the following piece of code which I would like to share with others who might find a need for it:
private void CreateMailItem()
{
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)outlookA
mailItem.Subject = this.txtSubject.Text;
mailItem.To = txtAddress.Text;
mailItem.Body = txtBody.Text;
mailItem.Importance = Outlook.OlImportance.olImp
mailItem.Display(false);
}
Éric Moreau: Right now I don't plan to include attachments to my code, but I am sure your article will be of help at some point in the future. Thank you
Adam
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you guys.
ASKER
Thank you