Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Sharepoint 2010-从web应用程序发送电子邮件时出现问题_C# - Fatal编程技术网

C# Sharepoint 2010-从web应用程序发送电子邮件时出现问题

C# Sharepoint 2010-从web应用程序发送电子邮件时出现问题,c#,C#,您好,我正在尝试从我自己的web部件发送一封来自Microsoft sharepoint 2010的电子邮件 我从两篇文章中进行了研究: 代码: 然而,我仍然面临着错误 请帮忙 objCurrentWeb = SPContext.Current.Web; foreach (SPListItem objJobApplicantsListItem in objJobApplicantsList.Items) {

您好,我正在尝试从我自己的web部件发送一封来自Microsoft sharepoint 2010的电子邮件 我从两篇文章中进行了研究:

代码:

然而,我仍然面临着错误 请帮忙

objCurrentWeb = SPContext.Current.Web;
 foreach (SPListItem objJobApplicantsListItem in objJobApplicantsList.Items)
                        {
                            if (objJobApplicantsListItem["First Name"].Equals(tempFirstName) && objJobApplicantsListItem["Last Name"].Equals(tempLastName))
                            {
                                objJobApplicantsListItem["Status"] = true;
                                objJobApplicantsListItem.Update();
                                //Logic for Sending Email:

                                bool fappendHtmlTag = false;
                                bool fhtmlEncode = false;
                                string toAddress = (string)objJobApplicantsListItem["Email"];
                                string subject = "Subject";
                                string message = "Message text";
                                //string 
                                //Check if the mail server is set:
                                bool isEmailServerSet = SPUtility.IsEmailServerSet(objCurrentWeb);
                                if(isEmailServerSet){
                                    try
                                    {
                                        bool result = SPUtility.SendEmail(objCurrentWeb, fappendHtmlTag, fhtmlEncode, toAddress, subject, message);
                                        //bool result = SPUtility.SendEmail(objCurrentWeb,message);
                                        if (result)
                                    {
                                        Label1.Text = "Email Sent";
                                    }
                                    else {
                                        Label1.Text = "Unsucessful send email";
                                    }
                                    }
                                    catch (Exception ex) {
                                        Label1.Text = ex.StackTrace;
                                    }
                                        /*
                                    if (result)
                                    {
                                        Label1.Text = "Email Sent";
                                    }
                                    else {
                                        Label1.Text = "Unsucessful send email";
                                    }*/
                                }
                                else{
                                    Label1.Text = "Email Sending Technical Error";

                                }

                            }
                        }