Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

Sending Email using SQL

$
0
0

I am trying to learn some more C# and I ran into something that I cannot find the solution too. I originally wrote this function in VB.NET and used a Code Converter to convert from VB to C#. One of the errors I am getting is

The name Interaction does not exist in the current context.

Is there a reference I am missing?

 public void EncompassEmail(string strLoanAssociates, string strSubject, string strBody)
        {
            var cmd;
            var sp;
            sp = "dbo.sp_send_dbmail";
            try
            {
                cmd = Interaction.CreateObject("ADODB.Command");
                {
                    var withBlock = cmd;
                    withBlock.ActiveConnection = "Provider=SQLOLEDB.1;Data Source=ACoolServer;Initial Catalog=MSDB;User ID=MailUser;Password=Goofy;";
                    withBlock.CommandType = 4;
                    withBlock.CommandText = sp;
                    withBlock.parameters("@recipients") = strLoanAssociates;
                    withBlock.parameters("@subject") = strSubject;
                    withBlock.parameters("@body") = strBody;
                    withBlock.parameters("@profile_name") = "EMail";
                    withBlock.parameters("@body_format") = "html";
                    withBlock.parameters("@importance") = "High";
                    withBlock.parameters("@sensitivity") = "Normal";
                    withBlock.Execute();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occured in the Email subroutine." + Constants.vbCrLf + strPlugin + Constants.vbCrLf + strVersion);
            }
            cmd = null;
        }

I get the error on the cmd = Interaction.CreateObject("ADODB.Command") line Thank you


Viewing all articles
Browse latest Browse all 29755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>