/// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(DfpUser user)
        {
            ReportService reportService = (ReportService)user.GetService(
                DfpService.v201611.ReportService);

            // Get the NetworkService.
            NetworkService networkService = (NetworkService)user.GetService(
                DfpService.v201611.NetworkService);

            // Set the file path where the report will be saved.
            String filePath = _T("INSERT_FILE_PATH_HERE");

            // Get the root ad unit ID to filter on.
            String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId;

            // Create statement to filter on an ancestor ad unit with the root ad unit ID to include all
            // ad units in the network.
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("PARENT_AD_UNIT_ID = :parentAdUnitId")
                                                .AddValue("parentAdUnitId", long.Parse(rootAdUnitId));

            // Create report query.
            ReportQuery reportQuery = new ReportQuery();

            reportQuery.dimensions =
                new Dimension[] { Dimension.AD_UNIT_ID, Dimension.AD_UNIT_NAME };
            reportQuery.columns = new Column[] { Column.AD_SERVER_IMPRESSIONS,
                                                 Column.AD_SERVER_CLICKS, Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_IMPRESSIONS,
                                                 Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_CLICKS,
                                                 Column.TOTAL_INVENTORY_LEVEL_IMPRESSIONS,
                                                 Column.TOTAL_INVENTORY_LEVEL_CPM_AND_CPC_REVENUE };

            // Set the filter statement.
            reportQuery.statement = statementBuilder.ToStatement();

            reportQuery.adUnitView    = ReportQueryAdUnitView.HIERARCHICAL;
            reportQuery.dateRangeType = DateRangeType.LAST_WEEK;

            // Create report job.
            ReportJob reportJob = new ReportJob();

            reportJob.reportQuery = reportQuery;

            try {
                // Run report.
                reportJob = reportService.runReportJob(reportJob);

                ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id);

                // Set download options.
                ReportDownloadOptions options = new ReportDownloadOptions();
                options.exportFormat                  = ExportFormat.CSV_DUMP;
                options.useGzipCompression            = true;
                reportUtilities.reportDownloadOptions = options;

                // Download the report.
                using (ReportResponse reportResponse = reportUtilities.GetResponse()) {
                    reportResponse.Save(filePath);
                }
                Console.WriteLine("Report saved to \"{0}\".", filePath);
            } catch (Exception e) {
                Console.WriteLine("Failed to run inventory report. Exception says \"{0}\"",
                                  e.Message);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the LineItemService.
            LineItemService lineItemService =
                (LineItemService)user.GetService(DfpService.v201602.LineItemService);
            // Get the ReportService.
            ReportService reportService =
                (ReportService)user.GetService(DfpService.v201602.ReportService);

            try {
                // Set the ID of the order to get line items from.
                long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

                // Set the file path where the report will be saved.
                String filePath = _T("INSERT_FILE_PATH_HERE");

                // Sets default for page.
                LineItemPage page = new LineItemPage();

                // Create a statement to only select line items from a given order.
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .Where("orderId = :orderId")
                                                    .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
                                                    .AddValue("orderId", orderId);


                // Collect all line item custom field IDs for an order.
                List <long> customFieldIds = new List <long>();
                do
                {
                    // Get line items by statement.
                    page = lineItemService.getLineItemsByStatement(statementBuilder.ToStatement());

                    // Get custom field IDs from the line items of an order.
                    if (page.results != null)
                    {
                        foreach (LineItem lineItem in page.results)
                        {
                            if (lineItem.customFieldValues != null)
                            {
                                foreach (BaseCustomFieldValue customFieldValue in lineItem.customFieldValues)
                                {
                                    if (!customFieldIds.Contains(customFieldValue.customFieldId))
                                    {
                                        customFieldIds.Add(customFieldValue.customFieldId);
                                    }
                                }
                            }
                        }
                    }

                    statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
                } while (statementBuilder.GetOffset() < page.totalResultSetSize);


                // Create statement to filter for an order.
                statementBuilder.RemoveLimitAndOffset();

                // Create report job.
                ReportJob reportJob = new ReportJob();

                // Create report query.
                ReportQuery reportQuery = new ReportQuery();
                reportQuery.dateRangeType  = DateRangeType.LAST_MONTH;
                reportQuery.dimensions     = new Dimension[] { Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME };
                reportQuery.statement      = statementBuilder.ToStatement();
                reportQuery.customFieldIds = customFieldIds.ToArray();
                reportQuery.columns        = new Column[] { Column.AD_SERVER_IMPRESSIONS };
                reportJob.reportQuery      = reportQuery;

                // Run report job.
                reportJob = reportService.runReportJob(reportJob);

                ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id);

                // Set download options.
                ReportDownloadOptions options = new ReportDownloadOptions();
                options.exportFormat                  = ExportFormat.CSV_DUMP;
                options.useGzipCompression            = true;
                reportUtilities.reportDownloadOptions = options;

                // Download the report.
                using (ReportResponse reportResponse = reportUtilities.GetResponse()) {
                    reportResponse.Save(filePath);
                }
                Console.WriteLine("Report saved to \"{0}\".", filePath);
            } catch (Exception e) {
                Console.WriteLine("Failed to run cusom fields report. Exception says \"{0}\"",
                                  e.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user, long savedQueryId)
        {
            using (ReportService reportService = user.GetService <ReportService>())
            {
                // Set the file path where the report will be saved.
                String filePath = _T("INSERT_FILE_PATH_HERE");

                // Create statement to retrieve the saved query.
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .Where("id = :id")
                                                    .OrderBy("id ASC")
                                                    .Limit(1)
                                                    .AddValue("id", savedQueryId);

                SavedQueryPage page =
                    reportService.getSavedQueriesByStatement(statementBuilder.ToStatement());
                SavedQuery savedQuery = page.results[0];

                if (!savedQuery.isCompatibleWithApiVersion)
                {
                    throw new InvalidOperationException("Saved query is not compatible with this " +
                                                        "API version");
                }

                // Optionally modify the query.
                ReportQuery reportQuery = savedQuery.reportQuery;
                reportQuery.adUnitView = ReportQueryAdUnitView.HIERARCHICAL;

                // Create a report job using the saved query.
                ReportJob reportJob = new ReportJob();
                reportJob.reportQuery = reportQuery;

                try
                {
                    // Run report.
                    reportJob = reportService.runReportJob(reportJob);

                    ReportUtilities reportUtilities =
                        new ReportUtilities(reportService, reportJob.id);

                    // Set download options.
                    ReportDownloadOptions options = new ReportDownloadOptions();
                    options.exportFormat                  = ExportFormat.CSV_DUMP;
                    options.useGzipCompression            = true;
                    reportUtilities.reportDownloadOptions = options;

                    // Download the report.
                    using (ReportResponse reportResponse = reportUtilities.GetResponse())
                    {
                        reportResponse.Save(filePath);
                    }

                    Console.WriteLine("Report saved to \"{0}\".", filePath);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to run saved query. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (ReportService reportService = user.GetService <ReportService>())
            {
                // Set the file path where the report will be saved.
                String filePath = _T("INSERT_FILE_PATH_HERE");

                long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

                // Create report job.
                ReportJob reportJob = new ReportJob();
                reportJob.reportQuery            = new ReportQuery();
                reportJob.reportQuery.dimensions = new Dimension[]
                {
                    Dimension.ORDER_ID,
                    Dimension.ORDER_NAME
                };
                reportJob.reportQuery.dimensionAttributes = new DimensionAttribute[]
                {
                    DimensionAttribute.ORDER_TRAFFICKER,
                    DimensionAttribute.ORDER_START_DATE_TIME,
                    DimensionAttribute.ORDER_END_DATE_TIME
                };
                reportJob.reportQuery.columns = new Column[]
                {
                    Column.AD_SERVER_IMPRESSIONS,
                    Column.AD_SERVER_CLICKS,
                    Column.AD_SERVER_CTR,
                    Column.AD_SERVER_CPM_AND_CPC_REVENUE,
                    Column.AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM
                };

                // Set a custom date range for the last 8 days
                reportJob.reportQuery.dateRangeType = DateRangeType.CUSTOM_DATE;
                System.DateTime endDateTime = System.DateTime.Now;
                reportJob.reportQuery.startDate = DateTimeUtilities
                                                  .FromDateTime(endDateTime.AddDays(-8), "America/New_York").date;
                reportJob.reportQuery.endDate = DateTimeUtilities
                                                .FromDateTime(endDateTime, "America/New_York").date;

                // Create statement object to filter for an order.
                StatementBuilder statementBuilder = new StatementBuilder().Where("ORDER_ID = :id")
                                                    .AddValue("id", orderId);
                reportJob.reportQuery.statement = statementBuilder.ToStatement();

                try
                {
                    // Run report job.
                    reportJob = reportService.runReportJob(reportJob);

                    ReportUtilities reportUtilities =
                        new ReportUtilities(reportService, reportJob.id);

                    // Set download options.
                    ReportDownloadOptions options = new ReportDownloadOptions();
                    options.exportFormat                  = ExportFormat.CSV_DUMP;
                    options.useGzipCompression            = true;
                    reportUtilities.reportDownloadOptions = options;

                    // Download the report.
                    using (ReportResponse reportResponse = reportUtilities.GetResponse())
                    {
                        reportResponse.Save(filePath);
                    }

                    Console.WriteLine("Report saved to \"{0}\".", filePath);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to run delivery report. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }
示例#5
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (ReportService reportService = user.GetService <ReportService>())
            {
                try
                {
                    // Set the ID of the custom field to report on.
                    long customFieldId = long.Parse(_T("INSERT_FIELD_ID_HERE"));

                    // Set the key ID of the custom dimension to report on.
                    long customDimensionKeyId =
                        long.Parse(_T("INSERT_CUSTOM_DIMENSION_KEY_ID_HERE"));

                    // Set the file path where the report will be saved.
                    String filePath = _T("INSERT_FILE_PATH_HERE");

                    // Create report job.
                    ReportJob reportJob = new ReportJob();

                    // Create report query.
                    ReportQuery reportQuery = new ReportQuery();
                    reportQuery.dateRangeType = DateRangeType.LAST_MONTH;
                    reportQuery.dimensions    = new Dimension[]
                    {
                        Dimension.CUSTOM_DIMENSION,
                        Dimension.LINE_ITEM_ID,
                        Dimension.LINE_ITEM_NAME
                    };
                    reportQuery.customFieldIds        = new long[] { customFieldId };
                    reportQuery.customDimensionKeyIds = new long[] { customDimensionKeyId };
                    reportQuery.columns = new Column[]
                    {
                        Column.AD_SERVER_IMPRESSIONS
                    };
                    reportJob.reportQuery = reportQuery;

                    // Run report job.
                    reportJob = reportService.runReportJob(reportJob);

                    ReportUtilities reportUtilities =
                        new ReportUtilities(reportService, reportJob.id);

                    // Set download options.
                    ReportDownloadOptions options = new ReportDownloadOptions();
                    options.exportFormat                  = ExportFormat.CSV_DUMP;
                    options.useGzipCompression            = true;
                    reportUtilities.reportDownloadOptions = options;

                    // Download the report.
                    using (ReportResponse reportResponse = reportUtilities.GetResponse())
                    {
                        reportResponse.Save(filePath);
                    }

                    Console.WriteLine("Report saved to \"{0}\".", filePath);
                }
                catch (Exception e)
                {
                    Console.WriteLine(
                        "Failed to run custom fields report. Exception says \"{0}\"", e.Message);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(DfpUser user)
        {
            using (ReportService reportService =
                       (ReportService)user.GetService(DfpService.v201802.ReportService))
            {
                // Set the file path where the report will be saved.
                String filePath = _T("INSERT_FILE_PATH_HERE");

                // Create report query.
                ReportQuery reportQuery = new ReportQuery();
                reportQuery.dimensions = new Dimension[]
                {
                    Dimension.AD_EXCHANGE_DATE,
                    Dimension.AD_EXCHANGE_COUNTRY_NAME
                };
                reportQuery.columns = new Column[]
                {
                    Column.AD_EXCHANGE_AD_REQUESTS,
                    Column.AD_EXCHANGE_IMPRESSIONS,
                    Column.AD_EXCHANGE_ESTIMATED_REVENUE
                };

                reportQuery.dateRangeType = DateRangeType.LAST_WEEK;

                // Run in pacific time.
                reportQuery.timeZoneType      = TimeZoneType.AD_EXCHANGE;
                reportQuery.adxReportCurrency = "EUR";

                // Create report job.
                ReportJob reportJob = new ReportJob();
                reportJob.reportQuery = reportQuery;

                try
                {
                    // Run report.
                    reportJob = reportService.runReportJob(reportJob);

                    ReportUtilities reportUtilities =
                        new ReportUtilities(reportService, reportJob.id);

                    // Set download options.
                    ReportDownloadOptions options = new ReportDownloadOptions();
                    options.exportFormat                  = ExportFormat.CSV_DUMP;
                    options.useGzipCompression            = true;
                    reportUtilities.reportDownloadOptions = options;

                    // Download the report.
                    using (ReportResponse reportResponse = reportUtilities.GetResponse())
                    {
                        reportResponse.Save(filePath);
                    }

                    Console.WriteLine("Report saved to \"{0}\".", filePath);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to run Ad Exchange report. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }
        /// <summary>
        /// Handles the Click event of the btnDownloadReport control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing
        /// the event data.</param>
        protected void OnDownloadReportButtonClick(object sender, EventArgs eventArgs)
        {
            ConfigureUserForOAuth();
            ReportService reportService =
                (ReportService)user.GetService(DfpService.v201802.ReportService);

            ReportQuery reportQuery = new ReportQuery();

            reportQuery.dimensions = new Dimension[]
            {
                Dimension.AD_UNIT_ID,
                Dimension.AD_UNIT_NAME
            };
            reportQuery.columns = new Column[]
            {
                Column.AD_SERVER_IMPRESSIONS,
                Column.AD_SERVER_CLICKS,
                Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_IMPRESSIONS,
                Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_CLICKS,
                Column.TOTAL_INVENTORY_LEVEL_IMPRESSIONS,
                Column.TOTAL_INVENTORY_LEVEL_CPM_AND_CPC_REVENUE
            };

            reportQuery.adUnitView    = ReportQueryAdUnitView.HIERARCHICAL;
            reportQuery.dateRangeType = DateRangeType.YESTERDAY;

            // Create report job.
            ReportJob reportJob = new ReportJob();

            reportJob.reportQuery = reportQuery;

            string filePath = Path.GetTempFileName();

            try
            {
                // Run report.
                reportJob = reportService.runReportJob(reportJob);

                ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id);

                // Set download options.
                ReportDownloadOptions options = new ReportDownloadOptions();
                options.exportFormat                  = ExportFormat.CSV_DUMP;
                options.useGzipCompression            = true;
                reportUtilities.reportDownloadOptions = options;

                // Download the report.
                using (ReportResponse reportResponse = reportUtilities.GetResponse())
                {
                    reportResponse.Save(filePath);
                }
            }
            catch (Exception e)
            {
                throw new System.ApplicationException("Failed to download report.", e);
            }

            Response.AddHeader("content-disposition", "attachment;filename=report.csv.gzip");
            Response.WriteFile(filePath);
            Response.End();
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="fileName">The file to which the report is downloaded.
        /// </param>
        public void Run(AdWordsUser user, string fileName)
        {
            ReportDefinition definition = new ReportDefinition()
            {
                reportName     = "Last 7 days CRITERIA_PERFORMANCE_REPORT",
                reportType     = ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT,
                downloadFormat = DownloadFormat.GZIPPED_CSV,
                dateRangeType  = ReportDefinitionDateRangeType.LAST_7_DAYS,

                selector = new Selector()
                {
                    fields = new string[]
                    {
                        "CampaignId",
                        "AdGroupId",
                        "Id",
                        "CriteriaType",
                        "Criteria",
                        "FinalUrls",
                        "Clicks",
                        "Impressions",
                        "Cost"
                    },
                    predicates = new Predicate[]
                    {
                        Predicate.In("Status", new string[]
                        {
                            "ENABLED",
                            "PAUSED"
                        })
                    }
                },
            };

            // Optional: Include zero impression rows.
            (user.Config as AdWordsAppConfig).IncludeZeroImpressions = true;

            // Optional: You can also skip the report headers, column headers and
            // report summary etc. to make the report parsing simpler.
            // (user.Config as AdWordsAppConfig).SkipColumnHeader = true;
            // (user.Config as AdWordsAppConfig).SkipReportHeader = true;
            // (user.Config as AdWordsAppConfig).SkipReportSummary = true;

            string filePath =
                ExampleUtilities.GetHomeDir() + Path.DirectorySeparatorChar + fileName;

            try
            {
                ReportUtilities utilities = new ReportUtilities(user, "v201806", definition);
                using (ReportResponse response = utilities.GetResponse())
                {
                    response.Save(filePath);
                }

                Console.WriteLine("Report was downloaded to '{0}'.", filePath);
            }
            catch (Exception e)
            {
                throw new System.ApplicationException("Failed to download report.", e);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>

        public void Run(AdWordsUser user)
        {
            //ReportQuery query = new ReportQueryBuilder()
            //    .Select("CampaignId", "AdGroupId", "Id", "Criteria", "CriteriaType",
            //        "Impressions", "Clicks", "Cost")
            //    .From(ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT)
            //    .Where("Status").In("ENABLED", "PAUSED")
            //    .During(ReportDefinitionDateRangeType.LAST_7_DAYS)
            //    .Build();

            //string filePath =
            //    ExampleUtilities.GetHomeDir() + Path.DirectorySeparatorChar + fileName;
            string DebugClientID = "";

            WriteLog("===========================Scheduler Started=========================================" + DateTime.Now);
            try
            {
                var     connectionString = ConfigurationManager.ConnectionStrings["AMS"].ConnectionString;             //"DATA SOURCE=10.108.135.231; UID=amslogin05; PWD=MoJ$t0$xAMSxps; INITIAL CATALOG=UAT_TRAINING_AMS;";//
                DataSet ds = new DataSet();

                SqlConnection conn = new SqlConnection(connectionString);
                if (conn.State.ToString() != "1")
                {
                    conn.Open();
                }

                SqlCommand cmd = new SqlCommand("select distinct GoogleAdWordsClientID from branch where isnull(GoogleAdWordsClientID,'0') <> '0' and GoogleAdWordsClientID<>'362-801-4584' ", conn);
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(ds);

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    string query = "SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, Impressions, " +
                                   "Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT WHERE Status IN [ENABLED, PAUSED] " +
                                   "DURING YESTERDAY";

                    ((Google.Api.Ads.AdWords.Lib.AdWordsAppConfig)user.Config).ClientCustomerId = row["GoogleAdWordsClientID"].ToString();

                    //string filePath = ExampleUtilities.GetHomeDir() + Path.DirectorySeparatorChar + fileName;
                    string filePath = ConfigurationManager.AppSettings["FolderPath"].ToString() + row["GoogleAdWordsClientID"].ToString() + ".csv";
                    DebugClientID = row["GoogleAdWordsClientID"].ToString();
                    try
                    {
                        ReportUtilities utilities = new ReportUtilities(user, "v201809", query,
                                                                        DownloadFormat.CSV.ToString());
                        using (ReportResponse response = utilities.GetResponse())
                        {
                            response.Save(filePath);
                        }
                        Console.WriteLine("Report was downloaded to '{0}'.", filePath);
                    }
                    catch (Exception e)
                    {
                        errorExisted = "yes";
                        //throw new System.ApplicationException("Failed to download report.", e);
                        WriteLog("*******************************Failed to download report for the Client ID=========================================" + DebugClientID);
                        WriteLog(e.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                errorExisted = "yes";
                WriteLog("*******************************ExCeption Starts for the Client ID=========================================" + DebugClientID);
                WriteLog(ex.ToString());
                WriteLog("*******************************ExCeption Ends=========================================");
                //throw;
            }
            finally
            {
                WriteLog("===========================Scheduler Ended=========================================" + DateTime.Now);

                string  SMTPCLIENT   = System.Configuration.ConfigurationManager.AppSettings["SMTPCLIENT"].ToString();
                string  MAILUSERNAME = System.Configuration.ConfigurationManager.AppSettings["MAILUSERNAME"].ToString();
                string  MAILPWD      = System.Configuration.ConfigurationManager.AppSettings["MAILPWD"].ToString();
                int     Port         = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Port"]);
                Boolean EnableSsl    = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["EnableSsl"]);

                System.Net.Mail.MailMessage msg;


                msg      = new System.Net.Mail.MailMessage();
                msg.Body = "Hi Team, <br><br> Please find the attached file for the Google AdWords log details. <br> <br> Thanks.";


                msg.From = new MailAddress("*****@*****.**");

                string[] strMails = ConfigurationManager.AppSettings["ToMail"].ToString().Split(';');
                for (int i = 0; i < strMails.Length - 1; i++)
                {
                    msg.To.Add(strMails[i].ToString());
                }


                if (errorExisted == "yes")
                {
                    msg.Subject = "Google AdWords Scheduler Status on " + System.DateTime.Today.ToString("MM-dd-yyyy") + " ****** Error Occurred **********";
                }
                else
                {
                    msg.Subject = "Google AdWords Scheduler Status on " + System.DateTime.Today.ToString("MM-dd-yyyy") + " ******* Run Successfully ******";
                }

                System.Net.Mail.SmtpClient   smtpServer  = null;
                System.Net.NetworkCredential credentials = null;
                smtpServer                       = new System.Net.Mail.SmtpClient(SMTPCLIENT);
                smtpServer.Port                  = Port;
                smtpServer.EnableSsl             = EnableSsl;
                smtpServer.UseDefaultCredentials = false;
                smtpServer.Port                  = Port;
                smtpServer.EnableSsl             = EnableSsl;
                smtpServer.UseDefaultCredentials = false;
                credentials                      = new System.Net.NetworkCredential(MAILUSERNAME, MAILPWD);
                smtpServer.Credentials           = credentials;
                smtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

                MemoryStream ms1  = new MemoryStream(File.ReadAllBytes(logFineName));
                Attachment   att1 = new System.Net.Mail.Attachment(ms1, "LogFile.txt");
                msg.Attachments.Add(att1);

                msg.IsBodyHtml         = true;
                smtpServer.Credentials = credentials;
                smtpServer.Send(msg);
            }
        }