Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, I converted some code from vb to c#. I am having troubles with one line:
mail = CreateObject("CDO.Message") this was the vb code. After converting to C#:
mail = Interaction.CreateObject("CDO.Message");
I am getting the error "The name interaction does not exist in the current context."
Do I need to include some sort of using directive or what? Any help would be greatly appreciated. I looked on Google, but did not have much luck.

Thank-you,
D
Posted

you may didn't add referance to this class 'Interaction'
 
Share this answer
 
In order to use the Interaction class, your C# project has to have a reference to Microsoft.VisualBasic.dll (see here[^]), which is a very heavy import for just one function.

The "proper" .NET way to do this is to use something like this (in .NET 4):
C#
dynamic comObject = Activator.CreateInstance(Type.GetTypeFromProgID(typeName, true));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900