D
Dilum
I've developed an Outlook add-in using VSTO 2005 and Office 2003 and C#. I've
added a new command bar with some buttons.
I need to get text from Clipboard to the message body upon clicking of one
of my buttons. I'm using hte following code.
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
mailItem.Body =
Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
else
mailItem.Body = "The clipboad does not contain any text\\links";
But I get the following error.
"Current thread must be set to single thread apartment(STA) mode before OLE
calls can be made. Ensure that your Main funciton has STAThreadAttribute
marked on it."
I tried putting [STAThread] attribute to methods and even created a new
thread and put [STAThread] to its target method. But still the error message
comes.
Is there any way to solve this issue.
Thanking you
Dilum
added a new command bar with some buttons.
I need to get text from Clipboard to the message body upon clicking of one
of my buttons. I'm using hte following code.
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
mailItem.Body =
Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
else
mailItem.Body = "The clipboad does not contain any text\\links";
But I get the following error.
"Current thread must be set to single thread apartment(STA) mode before OLE
calls can be made. Ensure that your Main funciton has STAThreadAttribute
marked on it."
I tried putting [STAThread] attribute to methods and even created a new
thread and put [STAThread] to its target method. But still the error message
comes.
Is there any way to solve this issue.
Thanking you
Dilum