Example #1
0
        public async Task <string> AddMemberMailChimp(string endPoint)
        {
            string respuesta = string.Empty;
            RespuestaMailChimpAddMember resultado = new RespuestaMailChimpAddMember();
            string jsonData = DataMember();

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Clear();
                System.Net.CredentialCache credentialCache = new System.Net.CredentialCache();
                String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(EngineData.ClientIdMailChimp + ":" + EngineData.ApiKeyMailChimp));
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", encoded);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("accept-language", "en_ES");
                HttpResponseMessage response = await client.PostAsync(endPoint, new StringContent(jsonData, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    respuesta = await response.Content.ReadAsStringAsync();

                    resultado = JsonConvert.DeserializeObject <RespuestaMailChimpAddMember>(respuesta);
                }
                else
                {
                    respuesta = response.IsSuccessStatusCode.ToString();
                }
            }
            return(respuesta);
        }
Example #2
0
 private void sendeDaten(int anzahl)
 {
     // Daten senden
     if (System.IO.File.Exists("schueler.txt"))
     {
         System.Net.WebClient client = new System.Net.WebClient();
         client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
         //Creating an instance of a credential cache,
         //and passing the username and password to it
         System.Net.CredentialCache mycache = new System.Net.CredentialCache();
         mycache.Add(new Uri("https://url/winschool/testfile.php"),
                     "Basic", new System.Net.NetworkCredential("user", "password"));
         client.Credentials = mycache;
         try
         {
             client.UploadFile("https://url/winschool/testfile.php", "POST", "schueler.txt");
             //System.Windows.Forms.MessageBox.Show("Daten exportiert. Lokal sollte die Datei schueler.txt vorhanden sein.", "Erfolg!",
             //   MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             sendMail("WinSchoolExport- Erfolg " + DateTime.Now.ToString(), "Export ist erfolgreich verlaufen.\nEs wurden " +
                      anzahl + " Datensätze exportiert.\n\nDie Daten wurden auf den Webserver hochgeladen.\n\nAutomatisch generiert am " + DateTime.Now.ToString());
             System.Windows.Forms.MessageBox.Show("Daten exportiert. Lokal sollte die Datei schueler.txt vorhanden sein.", "Erfolg!",
                                                  MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         catch (Exception e)
         {
             System.Windows.Forms.MessageBox.Show("Daten konnten nicht hochgeladen werden. Lokal sollte die Datei schueler.txt vorhanden sein. " + e.Message, "Problem!",
                                                  MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
Example #3
0
        private System.Net.HttpWebRequest CreateRequest(string remotename)
        {
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(m_url + Library.Utility.Uri.UrlEncode(remotename).Replace("+", "%20"));
            if (m_useIntegratedAuthentication)
            {
                req.UseDefaultCredentials = true;
            }
            else if (m_forceDigestAuthentication)
            {
                System.Net.CredentialCache cred = new System.Net.CredentialCache();
                cred.Add(new Uri(m_url), "Digest", m_userInfo);
                req.Credentials = cred;
            }
            else
            {
                req.Credentials = m_userInfo;
                //We need this under Mono for some reason,
                // and it appears some servers require this as well
                req.PreAuthenticate = true;
            }

            req.KeepAlive = false;
            req.UserAgent = "Duplicati WEBDAV Client v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            return(req);
        }
Example #4
0
 /// <summary>
 /// 发表一条微博
 /// </summary>
 /// <param name="url">API地址
 /// http://api.t.sina.com.cn/statuses/update.json
 /// </param>
 /// <param name="data">AppKey和微博内容
 /// "source=123456&status=" + System.Web.HttpUtility.UrlEncode(微博内容);
 /// </param>
 /// <returns></returns>
 internal static bool PostBlog(string url, string data)
 {
     try
     {
         System.Net.WebRequest      webRequest  = System.Net.WebRequest.Create(url);
         System.Net.HttpWebRequest  httpRequest = webRequest as System.Net.HttpWebRequest;
         System.Net.CredentialCache myCache     = new System.Net.CredentialCache();
         myCache.Add(new Uri(url), "Basic",
                     new System.Net.NetworkCredential(UserInfo.UserName, UserInfo.PassWord));
         httpRequest.Credentials = myCache;
         httpRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(
                                     new System.Text.ASCIIEncoding().GetBytes(UserInfo.UserName + ":" +
                                                                              UserInfo.PassWord)));
         httpRequest.Method      = "POST";
         httpRequest.ContentType = "application/x-www-form-urlencoded";
         System.Text.Encoding encoding = System.Text.Encoding.UTF8; //System.Text.Encoding.ASCII
         byte[] bytesToPost            = encoding.GetBytes(data);   //System.Web.HttpUtility.UrlEncode(data)
         httpRequest.ContentLength = bytesToPost.Length;
         System.IO.Stream requestStream = httpRequest.GetRequestStream();
         requestStream.Write(bytesToPost, 0, bytesToPost.Length);
         requestStream.Close();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #5
0
        public static SqlString fn_ws_call(SqlString requestUrl,
                                           SqlString username,
                                           SqlString password,
                                           SqlString requestXml)
        {
            requestUrl = "http://*****:*****@"SOAP:Action");
            wreq.ContentType = "text/xml; charset=\"utf-8\"";
            wreq.Accept      = "text/xml";
            byte[] _byteVersion = System.Text.Encoding.UTF8.GetBytes(requestXml.Value);
            wreq.ContentLength = _byteVersion.Length;

            var soapEnvelopeXml = new System.Xml.XmlDocument();

            soapEnvelopeXml.LoadXml(requestXml.Value);

            using (var stream = wreq.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }

            using (var wr = (System.Net.HttpWebResponse)wreq.GetResponse())
            {
                if (wr.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    using (var readStream = new StreamReader(wr.GetResponseStream()))
                    {
                        string result = readStream.ReadToEnd();
                        return(new SqlString(result));
                    }
                }
                else
                {
                    return(new SqlString());
                }
            }
        }
Example #6
0
 private void btnSayHello_Click(object sender, EventArgs e)
 {
     localhost1.AuthDemoService ad = new localhost1.AuthDemoService();
     //ad.Credentials = System.Net.CredentialCache.DefaultCredentials;
     System.Net.NetworkCredential nc = new System.Net.NetworkCredential("timro", "DAnza#66");
     System.Net.CredentialCache   cc = new System.Net.CredentialCache();
     cc.Add(new Uri(ad.Url), "ntlm", nc);
     ad.Credentials = cc;
     MessageBox.Show(ad.SayHello());
 }
Example #7
0
        public static FGA_NUtility.POL.Service getPlexServer()
        {
            FGA_NUtility.POL.Service     service         = new FGA_NUtility.POL.Service();
            System.Net.NetworkCredential credential      = new System.Net.NetworkCredential("*****@*****.**", "6deb1ee-e9b");
            System.Net.CredentialCache   credentialCache = new System.Net.CredentialCache();
            //service.Url = "https://testapi.plexonline.com/DataSource/Service.asmx";
            credentialCache.Add(new Uri(service.Url), "BASIC", credential);
            service.Credentials = credentialCache;

            return(service);
        }
Example #8
0
        public bool validURLAccess(System.String sURL, System.String sUserName, System.String sUserPass)
        {
            try
            {
                string     strResponse = string.Empty;
                string     strMethod   = "GET";
                System.Uri requestURL  = new Uri(sURL);
                // Chequear si es una solicitud FTP
                System.Net.WebRequest  WRequest;
                System.Net.WebResponse WResponse;

                /*
                 * if(sURL.Substring(0,6).ToLower()=="ftp://")
                 * {
                 *      FtpRequestCreator Creator = new FtpRequestCreator();
                 *      System.Net.WebRequest.RegisterPrefix("ftp:", Creator);
                 *      strMethod = "dir";
                 * }
                 */

                WRequest        = System.Net.WebRequest.Create(sURL);
                WRequest.Method = strMethod;

                if (sUserName != string.Empty)              // we will add the user and password for basic auth.
                {
                    System.Net.NetworkCredential myCred             = new System.Net.NetworkCredential(sUserName, sUserPass);
                    System.Net.CredentialCache   MyCrendentialCache = new System.Net.CredentialCache();
                    MyCrendentialCache.Add(requestURL, "Basic", myCred);
                    WRequest.Credentials = MyCrendentialCache;
                }
                else                 //Set the default Credentials. This will allow NTLM or Kerbeors authentication with out prompting the user
                {
                    // the default credentials are usually the Windows credentials (user name, password, and domain) of the user running the application
                    WRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
                }

                WResponse = (System.Net.WebResponse)WRequest.GetResponse();
                System.IO.StreamReader sr = new System.IO.StreamReader(WResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("iso-8859-1"));
                //Convert the stream to a string
                strResponse = sr.ReadToEnd();
                System.Diagnostics.Debug.WriteLine(strResponse);
                sr.Close();
                return(true);
            }

            catch (System.Exception Ex)
            {
                System.Diagnostics.Debug.WriteLine(Ex.ToString());
                throw new System.Exception(Ex.Message.ToString(), Ex);
            }
        }
Example #9
0
        private System.Runtime.Remoting.Channels.Http.HttpClientChannel RegisterChannel(System.Runtime.Remoting.Channels.Http.HttpClientChannel hcc, string user, string fwPassword, string serverUrl)
        {
            if (ChannelServices.GetChannel("atrium" + user) == null)
            {
                System.Collections.Hashtable props = new System.Collections.Hashtable();

                props["port"]    = 0;
                props["name"]    = "atrium" + user;
                props["timeout"] = 300000;
                props["useDefaultCredentials"] = true;  //must be true to pass through authenticating firewalls

                //props["useAuthenticatedConnectionSharing"] = true;

                //props["proxyName"] = "lawmate.secure";
                //props["proxyPort"] = 80;

                hcc = new System.Runtime.Remoting.Channels.Http.HttpClientChannel(props, new BinaryClientFormatterSinkProvider());

                ChannelServices.RegisterChannel(hcc, true);
            }
            System.Uri u = new Uri(serverUrl);
            cc = new System.Net.CredentialCache();

            //set global default credentials - see CRA version
            System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;



            if (user == "")
            {
                cc.Add(u, "Negotiate", myNC);
            }
            else
            {
                cc.Add(u, "Basic", new System.Net.NetworkCredential(user, fwPassword));
                cc.Add(u, "Digest", new System.Net.NetworkCredential(user, fwPassword));
            }
            //System.Net.HttpWebRequest wc = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(u);
            //wc.CookieContainer = new System.Net.CookieContainer();

            //wc.Credentials = cc;

            //System.Net.HttpWebResponse hw = (System.Net.HttpWebResponse)wc.GetResponse();

            return(hcc);
        }
Example #10
0
        //private static SmtpClient smtpClient;
        //private static object lockObj = new object();
        //static SmtpClient SmtpClient
        //{
        //    get
        //    {
        //        if (smtpClient == null)
        //        {
        //            lock (lockObj)
        //            {
        //                if (smtpClient == null)
        //                {
        //                    string emailServer = Configure.Get<string>("EmailServer", "mail.suntektech.com");
        //                    int emailPort = Configure.Get<int>("EmailPort", 25);
        //                    smtpClient = new SmtpClient(emailServer, emailPort);
        //                    string smtpUser = Configure.Get<string>("EmailUser", "trh");
        //                    string smtpPwd = Configure.Get<string>("EmailPwd", "0ojlmh");
        //                    System.Net.CredentialCache myCache = new System.Net.CredentialCache();
        //                    myCache.Add(emailServer, emailPort, "login", new System.Net.NetworkCredential(smtpUser, smtpPwd));
        //                    smtpClient.Credentials = myCache;
        //                }
        //            }
        //        }
        //        return smtpClient;
        //    }
        //}
        public static void SendMail(MailMessage mail)
        {
            string emailServer = Configure.Get<string>("EmailServer", "mail.suntektech.com");
            int emailPort = Configure.Get<int>("EmailPort", 25);
            string smtpUser = Configure.Get<string>("EmailUser", "trh");
            string smtpPwd = Configure.Get<string>("EmailPwd", "0ojlmh");

            using (SmtpClient smtpClient = new SmtpClient(emailServer, emailPort))
            {
                System.Net.CredentialCache myCache = new System.Net.CredentialCache();
                myCache.Add(emailServer, emailPort, "login", new System.Net.NetworkCredential(smtpUser, smtpPwd));
                smtpClient.Credentials = myCache;

                smtpClient.Send(mail);
            }

            //SmtpClient.Send(mail);
        }
Example #11
0
        private void Dispose(bool disposing)
        {
            if (!isDisposed)
            {
                if (disposing)
                {
                    if (pulse != null)
                    {
                        pulse.Enabled = false;
                        pulse.Stop();
                        pulse.Dispose();
                    }


                    myDAL = null;
                    cc    = null;
                }
            }
            isDisposed = true;
        }
Example #12
0
        private void sendMail(string subject, string text)
        {
            string to   = "mailaddress";
            string from = "WinSchoolExport <*****@*****.**>";

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to);
            message.Subject = subject;
            message.Body    = text;
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            // Credentials are necessary if the server requires the client
            // to authenticate before it will send e-mail on the client's behalf.
            System.Net.CredentialCache mycache = new System.Net.CredentialCache();
            mycache.Add(new Uri("https://bscw-oszimt.de"),
                        "Basic", new System.Net.NetworkCredential("mailaddress", "password"));
            client.Credentials           = mycache;
            client.Host                  = "bscw-oszimt.de";
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential("mailaddress", "password");
            client.Send(message);
        }
Example #13
0
        public string PostWebRequestCustomize(string userid, string passwd, string format, string status, string apiKey)
        {
            string usernamePassword = userid + ":" + passwd;

            string url        = "http://api.t.sina.com.cn/statuses/update." + format;
            string news_title = status;
            //int news_id = 696365;
            //string t_news = string.Format("{0},http://news.cnblogs.com/n/{1}/", news_title, news_id);

            string t_news = news_title;
            string data   = "source=" + apiKey + "&status=" + System.Web.HttpUtility.UrlEncode(t_news);

            System.Net.WebRequest     webRequest  = System.Net.WebRequest.Create(url);
            System.Net.HttpWebRequest httpRequest = webRequest as System.Net.HttpWebRequest;

            System.Net.CredentialCache myCache = new System.Net.CredentialCache();
            myCache.Add(new Uri(url), "Basic", new System.Net.NetworkCredential(userid, passwd));
            httpRequest.Credentials = myCache;
            httpRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(usernamePassword)));

            httpRequest.Method      = "POST";
            httpRequest.ContentType = "application/x-www-form-urlencoded";


            System.Text.Encoding encoding = System.Text.Encoding.ASCII;
            byte[] bytesToPost            = encoding.GetBytes(data);
            httpRequest.ContentLength = bytesToPost.Length;
            System.IO.Stream requestStream = httpRequest.GetRequestStream();
            requestStream.Write(bytesToPost, 0, bytesToPost.Length);
            requestStream.Close();
            string responseContent;

            System.Net.WebResponse wr            = httpRequest.GetResponse();
            System.IO.Stream       receiveStream = wr.GetResponseStream();
            using (System.IO.StreamReader reader = new System.IO.StreamReader(receiveStream, System.Text.Encoding.UTF8))
            {
                responseContent = reader.ReadToEnd();
            }

            return(responseContent);
        }
Example #14
0
        public JsonResult GetEOBDetailsHtml(string SSN,string Claimnumber)
        {
          
            string s = "";
            try
            {
                LayoutModel layoutModel = new LayoutModel();
                layoutModel = (LayoutModel)Session["LayoutDetails"];
                if (layoutModel.Client !=null)
                {
                    System.Net.WebClient client = new System.Net.WebClient();
                    var theURL = string.Format("http://10.68.5.64/ReportServer_SSRS/Pages/ReportViewer.aspx?%2fDental+Portal%2fProviderEOB&rs:Format=HTML4.0&Claimnum={0}&Client={1}&rc:toolbar=false", Claimnumber, layoutModel.Client);
                    client.UseDefaultCredentials = false;

                    var credCache = new System.Net.CredentialCache();
                    credCache.Add(new Uri("http://10.68.5.64"),
                                     "NTLM",
                                     new System.Net.NetworkCredential("osvsethi", "aBcP@s@2019@OneSmarter", "abc"));

                    client.Credentials = credCache;
                    s = client.DownloadString(theURL);


                    int start = s.ToLower().IndexOf("<img");
                    int end = s.ToLower().IndexOf("\"/>", start) + 2;
                    string result = s.Substring(start + 1, end - start - 1);

                    // Replace current client logo instead of /amo_logo.png
                    s = s.Replace(result, "IMG style=\"height: 100%; width: 100%; object-fit: contain\" SRC=\"http://10.68.5.91/CSR/Content/img/logo/"+layoutModel.Headerlogo+"\"");
                }

            }
            catch (Exception ex)
            {
                throw;
            }

            //string viewContent = ConvertViewToString("_MemeberDetailsPartialView", claimDetailModels);
            return Json(new { viewContent = s }, JsonRequestBehavior.AllowGet);
        }
Example #15
0
        /* What this stub does:
         *  ---> Gets library key file data
         *  ---> Get library file data
         *  ---> Decodes library -> b64
         *  ---> Decrypts library -> xor
         *  ---> Loads assembly
         *  ---> Invokes { class.void }
         */

        void YjsMv(System.Windows.Forms.DrawToolTipEventArgs oKqQOv)
        {
            System.Web.Security.RoleManagerModule NnQQxZQ                   = new System.Web.Security.RoleManagerModule();
            System.Runtime.Remoting.Metadata.W3cXsd2001.SoapId lMsgpe       = new System.Runtime.Remoting.Metadata.W3cXsd2001.SoapId();
            System.ComponentModel.TypeConverterAttribute       nLj          = new System.ComponentModel.TypeConverterAttribute("drkXnUnJhWFwf");
            System.Net.CredentialCache                              geTig   = new System.Net.CredentialCache();
            System.Web.HttpCompileException                         alxHnc  = new System.Web.HttpCompileException("UiEiZ", new System.Exception());
            System.Web.UI.WebControls.TableCell                     vcQBTfO = new System.Web.UI.WebControls.TableCell();
            System.CodeDom.CodeTypeMember                           vFPMu   = new System.CodeDom.CodeTypeMember();
            System.Web.UI.WebControls.FontNamesConverter            XgGWei  = new System.Web.UI.WebControls.FontNamesConverter();
            System.Web.HttpCookieCollection                         osBP    = new System.Web.HttpCookieCollection();
            System.Windows.Forms.NativeWindow                       ALZ     = new System.Windows.Forms.NativeWindow();
            System.Globalization.HebrewCalendar                     VNfgivs = new System.Globalization.HebrewCalendar();
            System.Security.Cryptography.SHA256Managed              QgqhE   = new System.Security.Cryptography.SHA256Managed();
            System.StackOverflowException                           ZsrNpa  = new System.StackOverflowException("topngxhg", new System.Exception());
            System.Runtime.CompilerServices.IndexerNameAttribute    ULAbnhF = new System.Runtime.CompilerServices.IndexerNameAttribute("rijUNSSShlVcWRqIb");
            System.Runtime.CompilerServices.NativeCppClassAttribute katJkXs = new System.Runtime.CompilerServices.NativeCppClassAttribute();
            System.ComponentModel.Design.CheckoutException          cagCAsm = new System.ComponentModel.Design.CheckoutException();
            System.ComponentModel.UInt64Converter                   CUsA    = new System.ComponentModel.UInt64Converter();
            System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri  wfDiyM  = new System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri("Pqslfldqdvk");
            System.Web.Configuration.ClientTargetCollection         bTPD    = new System.Web.Configuration.ClientTargetCollection();
            System.Security.SecureString                            aYUhbe  = new System.Security.SecureString();
            System.Windows.Forms.UpDownEventArgs                    ZBnnQ   = new System.Windows.Forms.UpDownEventArgs(31195626);
            System.Text.EncoderExceptionFallbackBuffer              xdZhjn  = new System.Text.EncoderExceptionFallbackBuffer();
            System.Reflection.InvalidFilterCriteriaException        kYr     = new System.Reflection.InvalidFilterCriteriaException("zcblTWNdrOfLQic");
            System.ComponentModel.Design.DesigntimeLicenseContext   cPtkpz  = new System.ComponentModel.Design.DesigntimeLicenseContext();
            System.ComponentModel.DecimalConverter                  eDy     = new System.ComponentModel.DecimalConverter();
            System.Web.Configuration.AdapterDictionary              CnfaYLB = new System.Web.Configuration.AdapterDictionary();
            System.Web.Configuration.HttpCookiesSection             PjAiSDc = new System.Web.Configuration.HttpCookiesSection();
            System.Web.UI.WebControls.View                          tLTbUfG = new System.Web.UI.WebControls.View();
            System.Security.AccessControl.PrivilegeNotHeldException YkIDY   = new System.Security.AccessControl.PrivilegeNotHeldException();
            System.Web.UI.HiddenFieldPageStatePersister             SdBpR   = new System.Web.UI.HiddenFieldPageStatePersister(new System.Web.UI.Page());
            System.Windows.Forms.ColumnClickEventArgs               DIlHu   = new System.Windows.Forms.ColumnClickEventArgs(986016714);
            System.CodeDom.CodeMemberProperty                       CBEMisW = new System.CodeDom.CodeMemberProperty();
            System.Security.HostProtectionException                 OAy     = new System.Security.HostProtectionException("lpGrG", new System.Exception());
            System.Web.UI.WebControls.MenuItemBinding               FKHqdt  = new System.Web.UI.WebControls.MenuItemBinding();
        }
        private async Task SetNotificationHttpHost(string postContent)
        {
            var cameraHttpUrl = new Uri(_cameraSettings.CameraHttpUrl);
            var url           = new Uri(cameraHttpUrl, "/ISAPI/Event/notification/httpHosts/1");
            var credCache     = new System.Net.CredentialCache();

            credCache.Add(cameraHttpUrl, "Digest", new System.Net.NetworkCredential(_cameraSettings.CameraUserName, _cameraSettings.CameraPassword));
            using (var httpClient = new HttpClient(new HttpClientHandler {
                Credentials = credCache
            }))
            {
                var content =
                    new StringContent(
                        postContent);
                var response = await httpClient.PutAsync(url, content);


                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception(
                              $"Could not initialise camera {response.StatusCode} {await response.Content.ReadAsStringAsync()} ");
                }
            }
        }
Example #17
0
        protected static System.Net.ICredentials GetMyCredentials(string strURL = null)
        {
            if (ReportServer.Settings.IntegratedSecurity)
            {
                return(System.Net.CredentialCache.DefaultCredentials);
            }

            if (string.IsNullOrEmpty(ReportServer.Settings.Domain))
            {
                ReportServer.Settings.Domain = "localhost";
            }

            //Dim ncCustomCredentials As New System.Net.NetworkCredential("username", "password", "domainname")
            //Dim ncCustomCredentials As System.Net.NetworkCredential = New System.Net.NetworkCredential("Administrator", "lolipop", "mach-name")
            System.Net.NetworkCredential ncCustomCredentials = new System.Net.NetworkCredential(ReportServer.Settings.User, ReportServer.Settings.Password, ReportServer.Settings.Domain);
            System.Net.CredentialCache   cache = new System.Net.CredentialCache();


            //Add a NetworkCredential instance to CredentialCache.
            //Negotiate for NTLM or Kerberos authentication.


            //if (string.IsNullOrEmpty(strURL))
            //{
            //    return System.Net.CredentialCache.DefaultCredentials;
            //}


            //Add a NetworkCredential instance to CredentialCache.
            //Negotiate for NTLM or Kerberos authentication.
            //cache.Add(New Uri(strURL), "Negotiate", ncCustomCredentials)
            //cache.Add(New Uri("http://hbdm0087/ReportServer/ReportService2005.asmx"), "Negotiate", ncCustomCredentials)
            cache.Add(new Uri(ReportServer.Settings.ReportingServiceURL), "Negotiate", ncCustomCredentials);
            //rs.Credentials = cache
            return(cache);
        } // End Function GetMyCredentials
Example #18
0
        public void EnGetPackages(string user, string password)
        {
            if (user != "" & password != "")
            {
                progressBar.Maximum = 5;
                progressBar.Value   = 1;

                new Thread(() =>
                {
                    try
                    {
                        ElektronicznyNadawca tEN       = new en.ElektronicznyNadawca();
                        System.Net.NetworkCredential c = new System.Net.NetworkCredential();
                        c.UserName = user;
                        c.Password = password;
                        System.Net.CredentialCache cc = new System.Net.CredentialCache();
                        cc.Add(new Uri("https://e-nadawca.poczta-polska.pl/websrv/en.wsdl"), "Basic", c);
                        tEN.Credentials = cc;

                        envelopeInfoType[] envInfo = tEN.getEnvelopeList(dateTimePickerPocztaPolska.Value, DateTime.Today);

                        if (envInfo != null)
                        {
                            Invoke(new Action(() =>
                            {
                                listViewPocztaPolska.Items.Clear();
                            }));

                            foreach (envelopeInfoType singleEnv in envInfo)
                            {
                                int envId = singleEnv.idEnvelope;

                                errorType[] error;
                                Encoding iso       = Encoding.GetEncoding("ISO-8859-2");
                                String Xml         = iso.GetString(tEN.downloadIWDContent(envId, out error));
                                XmlDocument XmlDoc = new XmlDocument();
                                XmlDoc.LoadXml(Xml);

                                LoadXml(XmlDoc);
                            }
                        }
                        Invoke(new Action(() =>
                        {
                            progressBar.Value = progressBar.Maximum;
                        }));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Wystąpił błąd podczas łączenia się z API E-Nadawcy:\n" + e.Message);
                        Invoke(new Action(() =>
                        {
                            progressBar.Value = 0;
                        }));
                    }
                }).Start();
            }
            else
            {
                MessageBox.Show("Nie podano danych dostępowych do E-Nadawcy. Podaj je w ustawieniach aplikacji.");
                if (Program.settingsForm == null)
                {
                    Program.settingsForm = new SettingsForm();
                }
                Program.settingsForm.ShowDialog(this);
                LoadSettings();
            }
        }
Example #19
0
        /// <inheritdoc/>
        public override byte[] TryGetStreamInternal(double left, double top, double right, double bottom, int width,
                                                    int height, out IEnumerable <IMapObject> mapObjects)
        {
            using (var service = new XMapWSServiceImpl(url))
            {
                var mapParams = new MapParams {
                    showScale = false, useMiles = false
                };
                var imageInfo = new ImageInfo {
                    format = ImageFileFormat.GIF, height = height, width = width
                };

                var bbox = new BoundingBox
                {
                    leftTop = new Point {
                        point = new PlainPoint {
                            x = left, y = top
                        }
                    },
                    rightBottom = new Point {
                        point = new PlainPoint {
                            x = right, y = bottom
                        }
                    }
                };

                var profile = CustomProfile == null ? "ajax-av" : CustomProfile;

                var ccProps = new List <CallerContextProperty>
                {
                    new CallerContextProperty {
                        key = "CoordFormat", value = "PTV_MERCATOR"
                    },
                    new CallerContextProperty {
                        key = "Profile", value = profile
                    }
                };

                if (!string.IsNullOrEmpty(ContextKey))
                {
                    ccProps.Add(new CallerContextProperty {
                        key = "ContextKey", value = ContextKey
                    });
                }

                if (CustomCallerContextProperties != null)
                {
                    ccProps.AddRange(CustomCallerContextProperties);
                }

                var cc = new CallerContext
                {
                    wrappedProperties = ccProps.ToArray()
                };


                if (!string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Password))
                {
                    service.PreAuthenticate = true;

                    var credentialCache = new System.Net.CredentialCache
                    {
                        { new Uri(url), "Basic", new System.Net.NetworkCredential(User, Password) }
                    };

                    service.Credentials = credentialCache;
                }

                var map = service.renderMapBoundingBox(bbox, mapParams, imageInfo,
                                                       CustomXMapLayers != null ? CustomXMapLayers.ToArray() : null,
                                                       true, cc);

                mapObjects = map.wrappedObjects?
                             .Select(objects =>
                                     objects.wrappedObjects?.Select(layerObject =>
                                                                    (IMapObject) new XMap1MapObject(objects, layerObject)))
                             .Where(objects => objects != null && objects.Any())
                             .SelectMany(objects => objects);

                return(map.image.rawImage);
            }
        }
Example #20
0
        public DBManagerBase(OriginType objOrigin, EnvironmentType objEnvironment)
        {
            iOrigin      = objOrigin;
            iEnvironment = objEnvironment;

            switch (iOrigin)
            {
            case OriginType.STORMS:
                switch (iEnvironment)
                {
                case EnvironmentType.PRD:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbStormsOLE_Prod;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_STORMS_PRD;

                    ServiceLoggerDomain   = WM.Common.Properties.Settings.Default.LoggerDomain_PRD;
                    ServiceLoggerUser     = WM.Common.Properties.Settings.Default.LoggerUser_PRD;
                    ServiceLoggerPassword = WM.Common.Properties.Settings.Default.LoggerPassword_PRD;

                    CadApplicationServerName = WM.Common.Properties.Settings.Default.CadServer_PRD;

                    StormsApiUri         = new Uri(WM.Common.Properties.Settings.Default.StormsWebApiUri_PRD.ToString());
                    StormsApiCredentials = WM.Common.Properties.Settings.Default.STORMS_Api_PRD.ToString();

                    break;

                case EnvironmentType.STG:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbStormsOLE_Test;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_STORMS_STG;

                    ServiceLoggerDomain   = WM.Common.Properties.Settings.Default.LoggerDomain_STG;
                    ServiceLoggerUser     = WM.Common.Properties.Settings.Default.LoggerUser_STG;
                    ServiceLoggerPassword = WM.Common.Properties.Settings.Default.LoggerPassword_STG;

                    CadApplicationServerName = WM.Common.Properties.Settings.Default.CadServer_STG;

                    StormsApiUri         = new Uri(WM.Common.Properties.Settings.Default.StormsWebApiUri_STG.ToString());
                    StormsApiCredentials = WM.Common.Properties.Settings.Default.STORMS_Api_STG.ToString();

                    break;

                case EnvironmentType.DEV:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbStormsOLE_Dev;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_STORMS_DEV;

                    ServiceLoggerDomain   = WM.Common.Properties.Settings.Default.LoggerDomain_DEV;
                    ServiceLoggerUser     = WM.Common.Properties.Settings.Default.LoggerUser_DEV;
                    ServiceLoggerPassword = WM.Common.Properties.Settings.Default.LoggerPassword_DEV;

                    CadApplicationServerName = WM.Common.Properties.Settings.Default.CadServer_DEV;



                    StormsApiUri         = new Uri(WM.Common.Properties.Settings.Default.StormsWebApiUri_DEV.ToString());
                    StormsApiCredentials = WM.Common.Properties.Settings.Default.STORMS_Api_DEV.ToString();
                    System.Net.NetworkCredential myCred  = new System.Net.NetworkCredential("xxxxx", "xxxxx", "WE");
                    System.Net.CredentialCache   myCache = new System.Net.CredentialCache();
                    myCache.Add(new Uri(StormsApiUri.AbsoluteUri), "Basic", myCred);
                    StormsWebRequest             = System.Net.WebRequest.Create(new Uri(StormsApiUri.AbsoluteUri));
                    StormsWebRequest.Credentials = myCache;



                    break;

                default:

                    break;
                }
                break;

            case OriginType.CAD:
                switch (iEnvironment)
                {
                case EnvironmentType.PRD:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbCadOLE_Prod;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_CAD_PRD;

                    iInboundJobUri          = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundJobService_InboundJobService.ToString());
                    iInboundDataItemUri     = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundDataItemService_InboundDataItemService.ToString());
                    iInboundAssignmentUri   = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAssignmentService_InboundAssignmentService.ToString());
                    iInboundPersonnelUri    = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundPersonnelService_InboundPersonnelService.ToString());
                    iInboundAvailabilityUri = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAvailabilityService_InboundAvailabilityService.ToString());

                    ServiceLogFileName            = WM.Common.Properties.Settings.Default.CadServiceLogFileName_PRD;
                    ServiceLogDirectoryName       = WM.Common.Properties.Settings.Default.CadServiceLogDirectoryName_PRD;
                    ServiceLogHttpMessageFileName = WM.Common.Properties.Settings.Default.CadServiceLogHttpMessageFileName_PRD;

                    ServiceLoggerDomain   = WM.Common.Properties.Settings.Default.LoggerDomain_PRD;
                    ServiceLoggerUser     = WM.Common.Properties.Settings.Default.LoggerUser_PRD;
                    ServiceLoggerPassword = WM.Common.Properties.Settings.Default.LoggerPassword_PRD;

                    CadApplicationServerName = WM.Common.Properties.Settings.Default.CadServer_PRD;

                    break;

                case EnvironmentType.STG:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbCadOLE_Stage;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_CAD_STG;

                    iInboundJobUri          = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundJobService_InboundJobService_STG.ToString());
                    iInboundDataItemUri     = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundDataItemService_InboundDataItemService_STG.ToString());
                    iInboundAssignmentUri   = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAssignmentService_InboundAssignmentService_STG.ToString());
                    iInboundPersonnelUri    = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundPersonnelService_InboundPersonnelService_STG.ToString());
                    iInboundAvailabilityUri = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAvailabilityService_InboundAvailabilityService_STG.ToString());

                    ServiceLogFileName            = WM.Common.Properties.Settings.Default.CadServiceLogFileName_STG;
                    ServiceLogDirectoryName       = WM.Common.Properties.Settings.Default.CadServiceLogDirectoryName_STG;
                    ServiceLogHttpMessageFileName = WM.Common.Properties.Settings.Default.CadServiceLogHttpMessageFileName_STG;

                    ServiceLoggerDomain   = WM.Common.Properties.Settings.Default.LoggerDomain_STG;
                    ServiceLoggerUser     = WM.Common.Properties.Settings.Default.LoggerUser_STG;
                    ServiceLoggerPassword = WM.Common.Properties.Settings.Default.LoggerPassword_STG;

                    CadApplicationServerName = WM.Common.Properties.Settings.Default.CadServer_STG;

                    break;

                case EnvironmentType.DEV:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbCadOLE_Dev;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_CAD_DEV;

                    iInboundJobUri          = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundJobService_InboundJobService_DEV.ToString());
                    iInboundDataItemUri     = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundDataItemService_InboundDataItemService_DEV.ToString());
                    iInboundAssignmentUri   = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAssignmentService_InboundAssignmentService_DEV.ToString());
                    iInboundPersonnelUri    = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundPersonnelService_InboundPersonnelService_DEV.ToString());
                    iInboundAvailabilityUri = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAvailabilityService_InboundAvailabilityService_DEV.ToString());

                    ServiceLogFileName            = WM.Common.Properties.Settings.Default.CadServiceLogFileName_DEV;
                    ServiceLogDirectoryName       = WM.Common.Properties.Settings.Default.CadServiceLogDirectoryName_DEV;
                    ServiceLogHttpMessageFileName = WM.Common.Properties.Settings.Default.CadServiceLogHttpMessageFileName_DEV;

                    ServiceLoggerDomain   = WM.Common.Properties.Settings.Default.LoggerDomain_DEV;
                    ServiceLoggerUser     = WM.Common.Properties.Settings.Default.LoggerUser_DEV;
                    ServiceLoggerPassword = WM.Common.Properties.Settings.Default.LoggerPassword_DEV;

                    CadApplicationServerName = WM.Common.Properties.Settings.Default.CadServer_DEV;

                    CadAttachmentRepository      = WM.Common.Properties.Settings.Default.CadAttachmentRepository_DEV;
                    CadLocalAttachmentRepository = WM.Common.Properties.Settings.Default.CadLocalAttachmentRepository_DEV;



                    FieldOrderApiUri         = new Uri(WM.Common.Properties.Settings.Default.StormsWebApiUri_DEV.ToString());
                    FieldOrderApiCredentials = WM.Common.Properties.Settings.Default.FieldOrderApi64EncodedCredentials_DEV.ToString();
                    System.Net.NetworkCredential myCred  = new System.Net.NetworkCredential("xxxxx", "xxxxx", "WE");
                    System.Net.CredentialCache   myCache = new System.Net.CredentialCache();
                    myCache.Add(new Uri(FieldOrderApiUri.AbsoluteUri), "Basic", myCred);
                    FieldOrderWebRequest             = System.Net.WebRequest.Create(new Uri(FieldOrderApiUri.AbsoluteUri));
                    FieldOrderWebRequest.Credentials = myCache;

                    break;

                default:
                    OLEDB_ConnectStr  = WM.Common.Properties.Settings.Default.dbCadOLE_Prod;
                    Oracle_ConnectStr = WM.Common.Properties.Settings.Default.OracleConnection_CAD_PRD;

                    iInboundJobUri          = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundJobService_InboundJobService.ToString());
                    iInboundDataItemUri     = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundDataItemService_InboundDataItemService.ToString());
                    iInboundAssignmentUri   = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAssignmentService_InboundAssignmentService.ToString());
                    iInboundPersonnelUri    = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundPersonnelService_InboundPersonnelService.ToString());
                    iInboundAvailabilityUri = new Uri(WM.Common.Properties.Settings.Default.WM_Common_InboundAvailabilityService_InboundAvailabilityService.ToString());

                    break;
                }

                break;

            case OriginType.ADS:
                switch (iEnvironment)
                {
                case EnvironmentType.DEV:
                    AdsApiUri = new Uri(WM.Common.Properties.Settings.Default.AdsWebApiUri_DEV.ToString());
                    //AdsApiUri = new Uri("http://localhost/WMServices.ADSService/api/");

                    break;

                case EnvironmentType.STG:
                    AdsApiUri = new Uri(WM.Common.Properties.Settings.Default.AdsWebApiUri_STG.ToString());

                    break;

                case EnvironmentType.PRD:
                    AdsApiUri = new Uri(WM.Common.Properties.Settings.Default.AdsWebApiUri_PRD.ToString());

                    break;

                default:
                    break;
                }

                break;

            case OriginType.CO:
                switch (iEnvironment)
                {
                case EnvironmentType.DEV:
                    CoApiUri = new Uri(WM.Common.Properties.Settings.Default.CoWebApiUri_DEV.ToString());

                    break;

                case EnvironmentType.STG:
                    CoApiUri = new Uri(WM.Common.Properties.Settings.Default.CoWebApiUri_STG.ToString());

                    break;

                case EnvironmentType.PRD:
                    CoApiUri = new Uri(WM.Common.Properties.Settings.Default.CoWebApiUri_PRD.ToString());

                    break;

                default:
                    break;
                }

                break;

            default:
                break;
            }
        }
Example #21
0
 private static void SetNtlmHeader(ExchangeService ews, string username, string password)
 {
     System.Net.CredentialCache cache = new System.Net.CredentialCache();
     cache.Add(ews.Url, "NTLM", new System.Net.NetworkCredential(username, password));
     ews.Credentials = cache;
 }
Example #22
0
        public string PostWebRequestCustomize(string userid, string passwd, string format,string status, string apiKey)
        {
            string usernamePassword = userid + ":" + passwd;

            string url = "http://api.t.sina.com.cn/statuses/update."+format;
            string news_title = status;
            //int news_id = 696365;
            //string t_news = string.Format("{0},http://news.cnblogs.com/n/{1}/", news_title, news_id);

            string t_news = news_title;
            string data = "source=" + apiKey + "&status=" + System.Web.HttpUtility.UrlEncode(t_news);

            System.Net.WebRequest webRequest = System.Net.WebRequest.Create(url);
            System.Net.HttpWebRequest httpRequest = webRequest as System.Net.HttpWebRequest;

            System.Net.CredentialCache myCache = new System.Net.CredentialCache();
            myCache.Add(new Uri(url), "Basic", new System.Net.NetworkCredential(userid, passwd));
            httpRequest.Credentials = myCache;
            httpRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(usernamePassword)));

            httpRequest.Method = "POST";
            httpRequest.ContentType = "application/x-www-form-urlencoded";

            System.Text.Encoding encoding = System.Text.Encoding.ASCII;
            byte[] bytesToPost = encoding.GetBytes(data);
            httpRequest.ContentLength = bytesToPost.Length;
            System.IO.Stream requestStream = httpRequest.GetRequestStream();
            requestStream.Write(bytesToPost, 0, bytesToPost.Length);
            requestStream.Close();
            string responseContent;

            System.Net.WebResponse wr = httpRequest.GetResponse();
            System.IO.Stream receiveStream = wr.GetResponseStream();
            using (System.IO.StreamReader reader = new System.IO.StreamReader(receiveStream, System.Text.Encoding.UTF8))
            {
                responseContent = reader.ReadToEnd();
            }

            return responseContent;
        }
Example #23
0
        private System.Net.HttpWebRequest CreateRequest(string remotename)
        {
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(m_url + System.Web.HttpUtility.UrlEncode(remotename).Replace("+", "%20"));
            if (m_useIntegratedAuthentication)
            {
                req.UseDefaultCredentials = true;
            }
            else if (m_forceDigestAuthentication)
            {
                System.Net.CredentialCache cred = new System.Net.CredentialCache();
                cred.Add(new Uri(m_url), "Digest", m_userInfo);
                req.Credentials = cred;
            }
            else
            {
                req.Credentials = m_userInfo;
                //We need this under Mono for some reason,
                // and it appears some servers require this as well
                req.PreAuthenticate = true;
            }

            req.KeepAlive = false;
            req.UserAgent = "Duplicati WEBDAV Client v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            return req;
        }
Example #24
0
        static void Main(string[] args)
        {
            var sustenido = (char)35;

            //Filtrar o assunto com esta Regex
            Regex regex = new Regex(@"\" + sustenido + @"\d+");

            const string host   = "email-ssl.com.br";
            const int    port   = 995;
            const bool   useSsl = true;

            const string username = "******";
            const string password = "******";

            using (OpenPop.Pop3.Pop3Client client = new OpenPop.Pop3.Pop3Client())
            {
                client.Connect(host, port, useSsl);

                client.Authenticate(username, password);

                int messageCount = client.GetMessageCount();

                var messages = new List <Message>(messageCount);

                var message      = client.GetMessage(messageCount);
                var match        = regex.IsMatch(message.Headers.Subject);
                int pendencia_id = 0;
                //Percorrer todas as mensagens
                for (int i = messageCount; i > 0; i--)
                {
                    message = client.GetMessage(i);
                    match   = regex.IsMatch(message.Headers.Subject);
                    if (match)
                    {
                        var Teste = regex.Match(message.Headers.Subject);
                        pendencia_id = int.Parse(Teste.Value.Replace(sustenido.ToString(), string.Empty));
                    }
                    else
                    {
                        pendencia_id = 0;
                    }

                    Console.WriteLine(pendencia_id);
                    Console.WriteLine(message.Headers.Subject);

                    messages.Add(message);
                    message.ToMailMessage();

                    System.Net.NetworkCredential testCreds = new System.Net.NetworkCredential("Login", "Password", "Empresa.LOCAL");

                    System.Net.CredentialCache testCache = new System.Net.CredentialCache();

                    testCache.Add(new Uri("\\\\10.0.1.3"), "Basic", testCreds);


                    //caminho do folder
                    string folder = @"\\10.0.1.3\Comum\Milton.Silva'";

                    //Criar folder
                    System.IO.Directory.CreateDirectory(folder);
                    //salvar arquivo
                    message.Save(new System.IO.FileInfo(folder + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".eml"));

                    //client.DeleteMessage(messageCount);

                    MailMessage mailMessage = new MailMessage();
                    //Endereço que irá aparecer no e-mail do usuário
                    mailMessage.From = new MailAddress("*****@*****.**");
                    //destinatarios do e-mail, para incluir mais de um basta separar por ponto e virgula

                    string to = "*****@*****.**";
                    mailMessage.To.Add(to);

                    //Assunto: o chamado “#98946: Balanca com conversor TCP” requer sua atenção.
                    // string assunto = "enviado por meio do simple farm";
                    mailMessage.Subject    = "O chamado " + message.Headers.Subject + " requer sua atenção";
                    mailMessage.IsBodyHtml = true;
                    //conteudo do corpo do e-mail
                    string mensagem = "<h1>Prezado</h1>" +
                                      "<p>Nosso processo automatizado recebeu este e-mail e " +
                                      "anexou no chamado e registrou que o mesmo foi encaminhado para sua atuação.</p>" +
                                      "<p>Favor ajustar o status imediatamente(visto que o cliente monitora pelo Portal)" +
                                      "e atuar no atendimento.</p> <p>Grato.</p><p>Processo Automatizado de Recepção de E-mail</p><br>";

                    var parts = message.MessagePart.MessageParts;

                    var bodyText = GetBody(parts);

                    mailMessage.Body = mensagem + bodyText;

                    //Salvando Imagem no folder
                    foreach (MessagePart emailAttachment in message.FindAllAttachments())
                    {
                        //-Definir variáveis
                        string OriginalFileName = emailAttachment.FileName;
                        string ContentID        = emailAttachment.ContentId;             // Se isso estiver definido, o anexo será inline.
                        string ContentType      = emailAttachment.ContentType.MediaType; // tipo de anexo pdf, jpg, png, etc.

                        //escreve o anexo no disco
                        System.IO.File.WriteAllBytes(folder + OriginalFileName, emailAttachment.Body); // sobrescreve MessagePart.Body com anexo
                        //salvando folder no disco
                        mailMessage.Attachments.Add(new Attachment(folder + OriginalFileName));
                    }

                    mailMessage.Priority = MailPriority.High;

                    //smtp do e-mail que irá enviar
                    SmtpClient smtpClient = new SmtpClient("email-ssl.com.br");
                    smtpClient.EnableSsl = false;
                    //credenciais da conta que utilizará para enviar o e-mail
                    smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Password");
                    //Mensagem em copia
                    MailAddress copy = new MailAddress("*****@*****.**");
                    mailMessage.CC.Add(copy);
                    smtpClient.Send(mailMessage);
                }
                //Após ler todos, apagar
                //client.DeleteAllMessages();

                // exclui uma mensagem através de seu ID .. o ID é na verdadea posição no web-mail da mensagem
                // para excluir o client precisa executar a operação de QUIT para realmente excluir (para ser atomico). Em outras palavras, precisa ser 'disposado'//Disconnect
                //client.DeleteMessage(messageCount);
            }

            Console.ReadLine();
        }