This topic is locked
[SOLVED]

 func.SendMail

9/13/2006 6:35:43 PM
ASPRunner.NET General questions
swat author


FirstName: James

LastName : Smith

Phone : 212 555 2222

[color=#FF0000]Question: Text TextText TextText TextText TextText TextText Text

field from the [color=#000099]it as body section of the email-
thx

Eugene 9/15/2006

try to use AfterAdd events with code :

func.SendMail("test@test.com", "Sample subject", e.Command.Parameters("Question").Value.ToString())

swat author 10/9/2006

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0118: 'System.Data.Common.DbCommand.Parameters' is a 'property' but is used like a 'method'
Source Error:
Line 26:

Line 27:

Line 28: func.SendMail("email@email.com", "Sample subject", e.Command.Parameters("Description").Value.ToString());

Line 29:

Line 30: }
Source File: e:\Inetpub\wwwroot\aspnet\App_Code\Table1_events.cs Line: 28

swat author 10/9/2006

Please note that this field is an rich-edit format

Eugene 10/11/2006

func.SendMail("test@test.com", "Sample subject", e.Command.Parameters["Question"].Value.ToString());

swat author 12/6/2006

Here is my code:

using System;

using System.Data;

using System.Web.UI.WebControls;

using System.Configuration;
public class CTable1_Events

{

public static void ViewOnLoad(System.Web.UI.Page Page)

{
//Display a message on the Web page
Page.Response.Write("Data");
//Send simple email

// do not forget to setup email parameters like From, SMTP server etc

// on 'Security->User login settings' dialog
func.SendMail("test@test.com", "Sample subject", e.Command.Parameters["Body"].Value.ToString());

}
}


Body section is and rich edited format text

ANd here is the result-
Server Error in '/net' Application.

--------------------------------------------------------------------------------
Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'e' does not exist in the current context
Source Error:
Line 18: // on 'Security->User login settings' dialog

Line 19:

Line 20: func.SendMail("test@test.com", "Sample subject", e.Command.Parameters["Body"].Value.ToString());

Line 21: }

Line 22:
Source File: c:\Inetpub\wwwroot\net\App_Code\Table1_events.cs Line: 20
Show Detailed Compiler Output:
c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\net\26cb9408\6ee7ea6b\assembly\dl3\4ee840bd\00d6412c_2377c501\FredCK.FCKeditorV2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\net\26cb9408\6ee7ea6b\App_Code.ycz87t0v.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\net\26cb9408\6ee7ea6b\App_Code.ycz87t0v.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\net\26cb9408\6ee7ea6b\App_Code.ycz87t0v.1.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\net\26cb9408\6ee7ea6b\App_Code.ycz87t0v.2.cs"
Microsoft ® Visual C# 2005 Compiler version 8.00.50727.42

for Microsoft ® Windows ® 2005 Framework version 2.0.50727

Copyright © Microsoft Corporation 2001-2005. All rights reserved.
c:\Inetpub\wwwroot\net\App_Code\Table1_events.cs(20,50): error CS0103: The name 'e' does not exist in the current context
Show Complete Compilation Source:
Line 1: using System;

Line 2: using System.Data;

Line 3: using System.Web.UI.WebControls;

Line 4: using System.Configuration;

Line 5:

Line 6: public class CTable1_Events

Line 7: {

Line 8: public static void ViewOnLoad(System.Web.UI.Page Page)Line 9: {Line 10:

Line 11: //Display a message on the Web page

Line 12:

Line 13: Page.Response.Write("Data");

Line 14:

Line 15:

Line 16: //Send simple email

Line 17: // do not forget to setup email parameters like From, SMTP server etc

Line 18: // on 'Security->User login settings' dialog

Line 19:

Line 20: func.SendMail("test@test.com", "Sample subject", e.Command.Parameters["Body"].Value.ToString());

Line 21: }

Line 22:

Line 23:

Line 24: }

Line 25:
--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
thanks

Eugene 12/7/2006

You can use "After record added" event.

public static void AfterAdd(System.Web.UI.Page Page, SqlDataSourceStatusEventArgs e)

{
//Send simple email

// do not forget to setup email parameters like From, SMTP server etc

// on 'Security->User login settings' dialog
func.SendMail("test@test.com", "Sample subject", e.Command.Parameters["Body"].Value.ToString());

}
swat author 12/7/2006

It works now, I can populate the Body section to email- however it is not HTML format-

I am using c# 2.0 version of the asprunner.net
thanks

Eugene 12/11/2006

Try to add this string into SendMail function (file lib.cs)
oMsg.BodyFormat = MailFormat.Html;

swat author 12/12/2006

Server Error in '/TWWI' Application.

--------------------------------------------------------------------------------
Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'oMsg' does not exist in the current context
Source Error:
Line 318: //send the message

Line 319: SmtpClient smtp = new SmtpClient(mailSmtpServer);

Line 320: oMsg.BodyFormat = MailFormat.Html;

Line 321: smtp.Port = Convert.ToInt32(mailSmtpPort);

Line 322:
Source File: e:\Inetpub\wwwroot\TWWI\App_Code\lib.cs Line: 320

Eugene 12/13/2006

mail.BodyFormat = MailFormat.Html;

swat author 12/13/2006

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'mail' does not exist in the current context
Source Error:
Line 319: if (string.IsNullOrEmpty(mailSender) || string.IsNullOrEmpty(mailTo)) return;

Line 320:

Line 321: mail.BodyFormat = MailFormat.Html;

Line 322: MailMessage mail = new MailMessage(mailSender, mailTo, subj, body);

Line 323:

Eugene 12/15/2006

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13910&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
MailMessage mail = new MailMessage(mailSender, mailTo, subj, body);

mail.BodyFormat = MailFormat.Html;