Implementing C# User Source - NameSpace
Just trying to Implement a simple User Source in C# and obviously not getting the correct Name space
Generated Code
using ObRun.ObEnvironment;
using ObRun.ObUtils;
// ***************************************************************************
// User requested imports
// ***************************************************************************
using System.Net;
using System.Net.Mail;
namespace UISimple{
In a subroutine in the code the Source is generated - but out of scope for the name space
how do I define the additional references so that they are in scope for the subroutine
// ***************************************************************************
// Subroutine: SendEmail
// ***************************************************************************
internal void ObSbr_PA19gF5()
{
// The standard set of context variables
PA19gF_ObDat v;
PA19gF_ObFnc fnc;
fnc = this;
// Initialise the standard set of context variables
v = (PA19gF_ObDat)fnc.DatVariable;
// Sub SendEmail
// API Call Source code: @TESTFunctions.NETSimple.SendEmail.SendEmail
System.NET.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.to.Add(v.getVariable(m_strVarPA19gF_Email).getAsObCharFldField(m_strVarUserEmail));
msg.Subject = "Subject Line";
msg.Body = "Message Body";
System.Net.Mail.SmtpClient sm = new System.Net.Mail.SmtpClient();
sm.Host = "email_server";
System.Net.NetworkCredential cred = new System.Net.Network.Credential();
cred.Username="username";
cred.password= "password";
sm.credentials = cred;
sm.Send(msg);
Using the Code wizard - I then get the following Error
UISimple\PA19gF_ObPnl.xaml.cs(742,16): error CS0234: The type or namespace name 'NET' does not exist in the namespace 'System' (are you missing an assembly reference?) [C:\PlexDev\GFSAPPPACT\Gen\Src\UISimpleUI.csproj]
UISimple\PA19gF_ObPnl.xaml.cs(748,60): error CS0234: The type or namespace name 'Network' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [C:\PlexDev\GFSAPPPACT\Gen\Src\UISimpleUI.csproj]
UISimple\PA19gF_ObPnl.xaml.cs(749,14): error CS1061: 'System.Net.NetworkCredential' does not contain a definition for 'Username' and no extension method 'Username' accepting a first argument of type 'System.Net.NetworkCredential' could be found (are you missing a using directive or an assembly reference?) [C:\PlexDev\GFSAPPPACT\Gen\Src\UISimpleUI.csproj]
UISimple\PA19gF_ObPnl.xaml.cs(750,14): error CS1061: 'System.Net.NetworkCredential' does not contain a definition for 'password' and no extension method 'password' accepting a first argument of type 'System.Net.NetworkCredential' could be found (are you missing a using directive or an assembly reference?) [C:\PlexDev\GFSAPPPACT\Gen\Src\UISimpleUI.csproj]
UISimple\PA19gF_ObPnl.xaml.cs(751,12): error CS1061: 'System.Net.Mail.SmtpClient' does not contain a definition for 'credentials' and no extension method 'credentials' accepting a first argument of type 'System.Net.Mail.SmtpClient' could be found (are you missing a using directive or an assembly reference?) [C:\PlexDev\GFSAPPPACT\Gen\Src\UISimpleUI.csproj]
Build completed with 5 Error(s).