这些值不会传入EmailTO
和传出EmailFrom
存储过程,它显示为 NULL。所以我无法发送电子邮件。如果我手动输入电子邮件地址To
,From
然后电子邮件以 smtp 形式发送,但它不是从存储过程中读取的。
请帮助我检索值:
这是我的存储过程,数据存储在表中:
Set @EmailFrom =(SELECT EmailFrom FROM tblEmailDesign where EmailID = @EmailID )
Set @EmailTo =(SELECT EmailTo FROM tblEmailDesign where EmailId = @EmailID )
Insert into tblEmailsend([EmailID][EmailSubject],[EmailTo],[EmailFrom],[EmailBody],[EmailComment])
select @EmailID @EmailFrom,@EmailTo,[EmailSubject],[EmailBody],@EmailComment from tblEmaildesign
where EmailID=@EmailID
END
这是我在 C# 中的调用代码:
protected void submit(object sender, EventArgs e)
SqlParameter EmailTo = new SqlParameter("@EmailTo", SqlDbType.NVarChar, 200);
EmailTo.Direction = ParameterDirection.Output;
scom.Parameters.Add(EmailTo);
SqlParameter EmailFrom = new SqlParameter("@EmailFrom", SqlDbType.NVarChar, 200);
EmailFrom.Direction = ParameterDirection.Output;
string To = EmailTo;
String FRom = EmailFrom;
scom.Parameters.Add(EmailFrom);
mail message = new mail();
mailsystem.Esendmail(To,From);
try {
scom.Connection.Open();
scom.ExecuteNonQuery();
scom.ExecuteReader(CommandBehavior.CloseConnection);
} finally {
scom.Connection.Close();
}
}
}