asp.net中调用SERVER的sp_send_dbmail的问题
using System;using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MCS.Core;
using MCS.DataService.DBService;
using System.Data.SqlClient;
namespace IIRS.AppMgt.SendMail
{
public partial class SendMail : System.Web.UI.Page
{
DBAccess db = new DBAccess();
protected void Page_Load(object sender, EventArgs e)
{
lblMsg.Visible = false;
if (!IsPostBack)
{
Bind_CheckBoxList();
}
}
/// <summary>
/// 油区的绑定
/// </summary>
private void Bind_CheckBoxList()
{
DataSet ds = db.GetDataSet("select Email,YQName from BaseData_YQ where YQName != '全国'");
chkListYQ.DataSource = ds;
chkListYQ.DataTextField = "YQName";
chkListYQ.DataValueField = "Email";
chkListYQ.DataBind();
}
protected void btnSend_Click(object sender, EventArgs e)
{
bool isSelectd = false;
for (int i = 0; i < chkListYQ.Items.Count; i++)
{
if (chkListYQ.Items[i].Selected == true)
{
isSelectd = true;
SqlParameter[] paralist = new SqlParameter[3];
paralist[0] = new SqlParameter("@mail", SqlDbType.NVarChar, 30);
paralist[0].Value = chkListYQ.Items[i].Value;
paralist[1] = new SqlParameter("@body", SqlDbType.VarChar, 300);
paralist[1].Value = txtaContent.Value;
paralist[2] = new SqlParameter("@subject", SqlDbType.VarChar, 20);
paralist[2].Value = txtName.Text.Trim();
db.ExecuteNonQuery("SendMail", paralist);
}
}
if (isSelectd == false)
{
lblMsg.Visible = true;
}
else
{
Response.Write("邮件已发送");
ClientScript.RegisterStartupScript(GetType(), "alert", "<script>alert('邮件已发送')</script>");
}
}
}
}
以上就是我写的代码,其中的那个SendMail存储过程调用的是SERVER自带的msdb..sp_send_dbmail 有4个参数,我把第一个参数直接写在SendMail里面了,运行程序的时候就抱 (profile 名称无效)
高手速度帮忙解决啊!~!~!~!~
先谢谢啦
--------------------编程问答-------------------- 沙发,帮顶上去 --------------------编程问答-------------------- You program account whether granted the authority to execute the SP
and you may open the configer setting in sys SP before.
or you can paste the error code in page --------------------编程问答-------------------- 还有这个参数呢@profile_name
补充:.NET技术 , C#