1

您好,我正在尝试通过我自己的 Web 部件从 Microsoft sharepoint 2010 发送一封电子邮件,我从两篇文章中进行了研究:http: //msdn.microsoft.com/en-us/library/ms460489.aspx http://sharepointgeorge。 com/2010/configuring-outgoing-email-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";

                                }

                            }
                        }

但是,我仍然面临错误请帮助

4

0 回答 0