Jump to content

lee212121

Members
  • Posts

    1
  • Joined

  • Last visited

lee212121's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. We have an old program which i believe is built using C# for which i have the source code but i cannot edit the program. The issue is we have moved our email to a new provider who is using STARTTLS for sending emails and our program is now failing to send a simple email and returning the error below; sendemail - Error in processing. The server response was: 5.7.3 STARTTLS is required to send mail [LO4P123CA0676.GBRP123.PROD.OUTLOOK.COM] We have an XML file which we can change the values of but i cannot see anywhere to add anything to allow the STARTTLS to work. The XML file contains the following; <Sage200_ImportSLsettings> <FileLocation> <FileLocation>D:\Sage\Sage Import Files</FileLocation> <Company>Volmary Ltd</Company> <MailServer>smtp-mail.outlook.com</MailServer> <MailTo>email</MailTo> <MailFrom>email</MailFrom> </FileLocation> </Sage200_ImportSLsettings> The C# code is shown below (which we are not able to edit) private void ReadXMLforConnectionDetails() { try { string path = Path.GetDirectoryName(Application.ExecutablePath) + @"\@CPS_Sage200_SLImport.xml"; if (File.Exists(path)) { IEnumerator enumerator; XmlDocument document = new XmlDocument(); document.Load(path); XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable); XmlNodeList list = document.DocumentElement.SelectNodes("/Sage200_ImportSLsettings/FileLocation", nsmgr); try { XmlNode current; enumerator = list.GetEnumerator(); goto TR_0018; TR_0008: try { this.MailFrom = current["MailFrom"].InnerText; } catch (Exception exception5) { ProjectData.SetProjectError(exception5); this.MailFrom = ""; ProjectData.ClearProjectError(); } goto TR_0018; TR_000B: try { this.MailTo = current["MailTo"].InnerText; } catch (Exception exception4) { ProjectData.SetProjectError(exception4); this.MailTo = ""; ProjectData.ClearProjectError(); } goto TR_0008; TR_000E: try { this.MailServer = current["MailServer"].InnerText; } catch (Exception exception3) { ProjectData.SetProjectError(exception3); this.MailServer = ""; ProjectData.ClearProjectError(); } goto TR_000B; TR_0011: try { this.SageCompany = current["Company"].InnerText; } catch (Exception exception2) { ProjectData.SetProjectError(exception2); this.SageCompany = ""; ProjectData.ClearProjectError(); } goto TR_000E; TR_0018: while (true) { if (enumerator.MoveNext()) { current = (XmlNode) enumerator.Current; try { this.FileLocation = current["FileLocation"].InnerText; } catch (Exception exception1) { ProjectData.SetProjectError(exception1); this.FileLocation = ""; ProjectData.ClearProjectError(); } } else { this.ConnecttoSage200(); return; } break; } goto TR_0011; } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } } this.WritetoErrorLog("ReadXMLforConnectionDetails() - File does not exist. " + path); Application.Exit(); } catch (Exception exception6) { Exception ex = exception6; ProjectData.SetProjectError(ex); Exception exception = ex; this.WritetoErrorLog("ReadXMLforConnectionDetails() - " + exception.Message); Application.Exit(); ProjectData.ClearProjectError(); } } private void sendemail(string MailSubject, string Emailbody) { try { MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient(this.MailServer); message.From = new MailAddress("\"CPS - Sage200 SL Import\"<" + this.MailFrom + ">"); message.To.Add(new MailAddress(this.MailTo)); message.Subject = MailSubject; message.IsBodyHtml = false; message.Body = Emailbody; client.Credentials = new NetworkCredential("email", "password"); client.Send(message); message.Dispose(); } catch (Exception exception1) { Exception ex = exception1; ProjectData.SetProjectError(ex); Exception exception = ex; this.WritetoErrorLog("sendemail - " + exception.Message); Application.Exit(); ProjectData.ClearProjectError(); } } Any advice will be greatly appreciated.
×
×
  • Create New...