本文整理汇总了C#中NetworkCredential类的典型用法代码示例。如果您正苦于以下问题:C# NetworkCredential类的具体用法?C# NetworkCredential怎么用?C# NetworkCredential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkCredential类属于命名空间,在下文中一共展示了NetworkCredential类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
locator.locate find = new locator.locate();
String j = bgroup.Text;
String[] emailList= find.mailing(j);
// string a = group.Text;
// a = a + ", [email protected],[email protected]";
//List<String> emailList=null;
//emailList.
string a="";
foreach(String eachItem in emailList){
a = eachItem+", "+a;
}
a = a.Substring(0, a.Length - 2);
string b = body.Text;
MailMessage MyMailMessage = new MailMessage("[email protected]", a,"Donor Notifications", b);
MyMailMessage.IsBodyHtml = false;
NetworkCredential mailAuthentication = new NetworkCredential("[email protected]", "giveblood");
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.Send(MyMailMessage);
Label1.Text = "Sent Notifications Successfully";
}
示例2: ProxyExplicitlyProvided_DefaultCredentials_Ignored
public void ProxyExplicitlyProvided_DefaultCredentials_Ignored()
{
int port;
Task<LoopbackGetRequestHttpProxy.ProxyResult> proxyTask = LoopbackGetRequestHttpProxy.StartAsync(out port, requireAuth: true, expectCreds: true);
Uri proxyUrl = new Uri($"http://localhost:{port}");
var rightCreds = new NetworkCredential("rightusername", "rightpassword");
var wrongCreds = new NetworkCredential("wrongusername", "wrongpassword");
using (var handler = new HttpClientHandler())
using (var client = new HttpClient(handler))
{
handler.Proxy = new UseSpecifiedUriWebProxy(proxyUrl, rightCreds);
handler.DefaultProxyCredentials = wrongCreds;
Task<HttpResponseMessage> responseTask = client.GetAsync(Configuration.Http.RemoteEchoServer);
Task<string> responseStringTask = responseTask.ContinueWith(t => t.Result.Content.ReadAsStringAsync(), TaskScheduler.Default).Unwrap();
Task.WaitAll(proxyTask, responseTask, responseStringTask);
TestHelper.VerifyResponseBody(responseStringTask.Result, responseTask.Result.Content.Headers.ContentMD5, false, null);
Assert.Equal(Encoding.ASCII.GetString(proxyTask.Result.ResponseContent), responseStringTask.Result);
string expectedAuth = $"{rightCreds.UserName}:{rightCreds.Password}";
Assert.Equal(expectedAuth, proxyTask.Result.AuthenticationHeaderValue);
}
}
示例3: Ctor_UserNamePasswordDomain_Success
public static void Ctor_UserNamePasswordDomain_Success()
{
NetworkCredential nc = new NetworkCredential("username", "password", "domain");
Assert.Equal("username", nc.UserName);
Assert.Equal("password", nc.Password);
Assert.Equal("domain", nc.Domain);
}
示例4: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
MailAddress mailadd = new MailAddress("[email protected]","Amita Shukla");
msg.From = mailadd;
msg.To.Add(new MailAddress(TextBox1.Text));
msg.Subject = TextBox2.Text;
msg.Body = TextBox4.Text;
if (FileUpload1.HasFile)
{
msg.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
}
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
NetworkCredential nkc = new NetworkCredential("[email protected]", "*******");
smtp.Credentials = nkc;
smtp.EnableSsl = true;
try
{
smtp.Send(msg);
Label5.Text = "Email sent successfully";
}
catch(Exception ex)
{
Label5.Text = ex.Message;
}
}
示例5: SendMail
public static bool SendMail(string gMailAccount, string password, string to, string subject, string message)
{
try
{
NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(gMailAccount);
msg.To.Add(new MailAddress(to));
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
return true;
}
catch (Exception)
{
return false;
}
}
示例6: EmailNotification
void EmailNotification()
{
MailMessage mm = new MailMessage();
mm.From = new MailAddress("[email protected]");
mm.To.Add(txtEmail.Text.ToString());
mm.Subject = "Feedback - Inquiry/Issue";
string body = "Hello " + txtFirstName.Text.Trim() + ",";
body += "<br /><br />Thank you for sending us a message";
body += "<br /><br />we will get back to you shortly using the email " + txtEmail.Text.ToString();
body += "<br /><br />Thanks";
body += "<br /><br />";
body += "<br /><br />Customer Care - Lifeline Ambulance Rescue Inc.,";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.UseDefaultCredentials = true;
NetworkCredential cred = new NetworkCredential("[email protected]", "swantonbomb");
client.Host = "smtp.gmail.com";
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = cred;
client.Send(mm);
}
示例7: ValidateCreateContext
internal void ValidateCreateContext(
string package,
NetworkCredential credential,
string servicePrincipalName,
ExtendedProtectionPolicy policy,
ProtectionLevel protectionLevel,
TokenImpersonationLevel impersonationLevel)
{
if (policy != null)
{
// One of these must be set if EP is turned on
if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null)
{
throw new ArgumentException(SR.net_auth_must_specify_extended_protection_scheme, nameof(policy));
}
_extendedProtectionPolicy = policy;
}
else
{
_extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
}
ValidateCreateContext(package, true, credential, servicePrincipalName, _extendedProtectionPolicy.CustomChannelBinding, protectionLevel, impersonationLevel);
}
示例8: Start
// Use this for initialization
void Start () {
PlaneXML = new PlaneXMLv1 ();
c = new NetworkCredential("[email protected]", "B8955E7C-C03F-4CF9-9B8D-C38C50FDA67A");
PlaneXML.Credentials = c;
flight = PlaneXML.FlightInfo(flightID, true, true);
StartCoroutine("refresh");
}
示例9: brnSendEmail_Click
protected void brnSendEmail_Click(object sender, EventArgs e)
{
lblMessage.ForeColor = Color.Green;
lblMessage.Text = "";
try
{
// initialize exchange client
NetworkCredential credential = new NetworkCredential(txtUsername.Text, Session["Password"].ToString(), txtDomain.Text);
Aspose.Email.Exchange.ExchangeClient client = new Aspose.Email.Exchange.ExchangeClient(txtHost.Text, credential);
// build message
MailMessage msg = new MailMessage();
msg.From = txtFrom.Text;
msg.To = txtTo.Text;
msg.Subject = txtSubject.Text;
msg.TextBody = txtTextBody.Text;
// send email
client.Send(msg);
lblMessage.Text = "Successfully sent email using Microsoft Exchange server.<br><hr>";
}
catch (Exception ex)
{
lblMessage.ForeColor = Color.Red;
lblMessage.Text = "Error: " + ex.Message;
}
}
示例10: SendMail
public bool SendMail(ArrayList toAdresses)
{
SmtpClient smtpClient = new SmtpClient(adminMailServer, adminMailPort);
NetworkCredential networkCredential = new NetworkCredential(adminMailAddress, adminMailPassword);
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = networkCredential;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(adminMailAddress, appName);
for (int i = 0; i < (toAdresses.Count); i++)
{
mail.To.Add(new MailAddress(toAdresses[i].ToString()));
}
mail.Subject = appName + " - Mail Notification";
mail.IsBodyHtml = true;
mail.Body = MessageModifier();
//mail.Priority = MailPriority.High;
try
{
smtpClient.Send(mail);
return true;
}
catch
{
return false;
}
}
示例11: sendReceipt
//Now in ppClass_sb.cs
//get expired permits and reset spots to unoccupied
//private void _resetSpots()
//{
// //get expired spots
// var expiredSpots = objPark.getExpiredPermits(DateTime.Now);
// foreach (var spot in expiredSpots)
// {
// var spotSingle = objPark.getSpotBySpot(spot.spot);
// }
//}
//Send Email Receiptfd
protected void sendReceipt(DateTime _timeExp, string _spot)
{
//This is the script provided by my hosting to send mail (Source URL: https://support.gearhost.com/KB/a777/aspnet-form-to-email-example.aspx?KBSearchID=41912)
try
{
//Create the msg object to be sent
MailMessage msg = new MailMessage();
//Add your email address to the recipients
msg.To.Add(txt_email.Text);
//Configure the address we are sending the mail from
MailAddress address = new MailAddress("[email protected]");
msg.From = address;
//Append their name in the beginning of the subject
msg.Subject = "Your KDH Parking Reciept";
msg.Body = "Thank you for parking with us. You are parked in " + _spot + " and your permit expires at " + _timeExp.ToString(@"hh\:mm\:ss") + ".";
//Configure an SmtpClient to send the mail.
SmtpClient client = new SmtpClient("mail.stevebosworth.ca");
client.EnableSsl = false; //only enable this if your provider requires it
//Setup credentials to login to our sender email address ("UserName", "Password")
NetworkCredential credentials = new NetworkCredential("[email protected]", "Pa55w0rd!");
client.Credentials = credentials;
//Send the msg
client.Send(msg);
}
catch
{
//If the message failed at some point, let the user know
lbl_message.Text = "Your message failed to send, please try again.";
}
}
示例12: Submit_Click
protected void Submit_Click(object sender, EventArgs e)
{
MailAddress mailFrom = new MailAddress("[email protected].com");
MailAddress mailTo = new MailAddress("[email protected]");
MailMessage emailMessage = new MailMessage(mailFrom, mailTo);
emailMessage.Subject = "Unsubscribe";
emailMessage.Body += "<br>Email: " + email.Text;
emailMessage.IsBodyHtml = false;
SmtpClient myMail = new SmtpClient();
myMail.Host = "localhost";
myMail.DeliveryMethod = SmtpDeliveryMethod.Network;
//myMail.Port = 25;
NetworkCredential SMTPUserInfo = new NetworkCredential("[email protected]", "!p3Learning", "pinnacle3learning.com");
//myMail.UseDefaultCredentials = false;
myMail.Credentials = SMTPUserInfo;
myMail.Send(emailMessage);
MultiView1.ActiveViewIndex = 1;
}
示例13: AuthenticateAsClient
//
public virtual void AuthenticateAsClient( NetworkCredential credential,
string targetName,
ProtectionLevel requiredProtectionLevel, //this will be the ultimate result or exception
TokenImpersonationLevel allowedImpersonationLevel) //this OR LOWER will be ultimate result in auth context
{
AuthenticateAsClient(credential, null, targetName, requiredProtectionLevel, allowedImpersonationLevel);
}
示例14: brnSendEmail_Click
protected void brnSendEmail_Click(object sender, EventArgs e)
{
lblMessage.Text = "";
lblMessage.ForeColor = Color.Green;
try
{
// initialize exchange client
NetworkCredential credential = new NetworkCredential(txtUsername.Text, txtPassword.Text, txtDomain.Text);
Aspose.Email.Exchange.ExchangeWebServiceClient client = new Aspose.Email.Exchange.ExchangeWebServiceClient(txtHost.Text, credential);
// get mailbox and folders information
Aspose.Email.Exchange.ExchangeMailboxInfo exchangeMailboxInfo = client.GetMailboxInfo();
lblMailboxURI.Text = exchangeMailboxInfo.MailboxUri;
lblInboxURI.Text = exchangeMailboxInfo.InboxUri;
lblSentItemsURI.Text = exchangeMailboxInfo.SentItemsUri;
lblDraftsURI.Text = exchangeMailboxInfo.DraftsUri;
lblCalendarURI.Text = exchangeMailboxInfo.CalendarUri;
lblDeletedItemsURI.Text = exchangeMailboxInfo.DeletedItemsUri;
lblMessage.Text = "Successfully connected to Microsoft Exchange server.<br><hr>";
}
catch (Exception ex)
{
lblMessage.ForeColor = Color.Red;
lblMessage.Text = "Error: " + ex.Message;
}
}
开发者ID:williamesharp,项目名称:Aspose_Email_NET,代码行数:28,代码来源:Exchange-Server-Mailbox-Folder-Information-EWS.aspx.cs
示例15: EmailForActivationRegistry
public string EmailForActivationRegistry(string emailOfUser, MailMessage mail)
{
string status = "";
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "smtp.gmail.com";
smtpClient.EnableSsl = true;
smtpClient.Port = 587;
smtpClient.UseDefaultCredentials = true;
NetworkCredential networkCred = new NetworkCredential("[email protected]", "ULatina506");
smtpClient.Credentials = networkCred;
try
{
smtpClient.Send(mail);
status = "Enviado";
}
catch
{
status = "No Enviado";
}
return status;
}