當前位置: 首頁>>代碼示例>>C#>>正文


C# SendGridMessage.DisableUnsubscribe方法代碼示例

本文整理匯總了C#中SendGrid.SendGridMessage.DisableUnsubscribe方法的典型用法代碼示例。如果您正苦於以下問題:C# SendGridMessage.DisableUnsubscribe方法的具體用法?C# SendGridMessage.DisableUnsubscribe怎麽用?C# SendGridMessage.DisableUnsubscribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SendGrid.SendGridMessage的用法示例。


在下文中一共展示了SendGridMessage.DisableUnsubscribe方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Send

        public void Send(SendGridMessage message)
        {
            // Create network credentials to access your SendGrid account.
            var credentials = new NetworkCredential(_sendGridUsername, _sendGridPassword);

            // Create an Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Disable Unsubsribe
            message.DisableUnsubscribe();

            var email = ConfigurationManager.AppSettings["TestNotifications"];

            var testMessage = new SendGridMessage
            {
                Subject = message.Subject,
                Html = message.Html,
                Attachments = message.Attachments,
                StreamedAttachments = message.StreamedAttachments
            };

            testMessage.AddTo(email);
            testMessage.From = new MailAddress("[email protected]", "AquaCulture Monitor");

            transportWeb.Deliver(testMessage);
        }
開發者ID:devfunkd,項目名稱:aquaponic-raspberry-pi,代碼行數:26,代碼來源:SendGridGateway.cs

示例2: Test_DisablingUnsubscribe

        public void Test_DisablingUnsubscribe()
        {
            var mail = BasicMailBuilder
                .DisableUnsubscribe()
                .Build();

            var message = new SendGridMessage();
            message.DisableUnsubscribe();
            Assert.IsFalse(string.IsNullOrEmpty(message.Header.JsonString()));
            Assert.AreEqual(message.Header.JsonString(), mail.Header.JsonString());
        }
開發者ID:saluce65,項目名稱:sendgrid-csharp-mailbuilder,代碼行數:11,代碼來源:UnitTest1.cs

示例3: SendEmailViaSendGrid

        public static void SendEmailViaSendGrid(string to, string from, string subject, string htmlBody, MailType type, string textBody, string[] multipleTo = null)
        {
            try
            {
                //var message = SendGrid.GenerateInstance();
                var message = new SendGridMessage();
                if (String.IsNullOrEmpty(to))
                    message.AddTo(multipleTo);
                else
                    message.AddTo(to);

                //if (multipleTo != null)
                //    message.AddTo(multipleTo);
                //else
                //    message.AddTo(to);

                message.From = new System.Net.Mail.MailAddress(from);
                message.Subject = subject;
                if (type == MailType.TextOnly)
                    message.Text = textBody.Replace(@"\r\n", Environment.NewLine);
                else if (type == MailType.HtmlOnly)
                    message.Html = htmlBody;
                else
                {
                    message.Html = htmlBody;
                    message.Text = textBody;
                }

                //Dictionary<string, string> collection = new Dictionary<string, string>();
                //collection.Add("header", "header");
                //message.Headers = collection;

                message.EnableOpenTracking();
                message.EnableClickTracking();
                message.DisableUnsubscribe();
                message.DisableFooter();
                message.EnableBypassListManagement();
                //var transportInstance = SMTP.GenerateInstance(new System.Net.NetworkCredential(SendGridUsername, SendGridPassword), SendGridSmtpHost, SendGridSmtpPort);
                var transportInstance = new Web(new System.Net.NetworkCredential(SendGridUsername, SendGridPassword));
                transportInstance.Deliver(message);
                if (String.IsNullOrEmpty(to))
                    Console.WriteLine("SendGrid: Email was sent successfully to " + multipleTo);
                else
                    Console.WriteLine("SendGrid: Email was sent successfully to " + to);
            }
            catch (Exception)
            {
                if (String.IsNullOrEmpty(to))
                    Console.WriteLine("SendGrid: Unable to send email to " + multipleTo);
                else
                    Console.WriteLine("SendGrid: Unable to send email to " + to);
                throw;
            }
        }
開發者ID:agentvnod,項目名稱:tfctvoldcode,代碼行數:54,代碼來源:RecurringProcessor.cs

示例4: DisableUnsubscribe

        public void DisableUnsubscribe()
        {
            var header = new Header();
            var sendgrid = new SendGridMessage(header);

            sendgrid.DisableUnsubscribe();

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
開發者ID:npadmanabhan,項目名稱:sendgrid-csharp,代碼行數:10,代碼來源:TestSendgrid.cs


注:本文中的SendGrid.SendGridMessage.DisableUnsubscribe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。