本文整理汇总了C#中Email类的典型用法代码示例。如果您正苦于以下问题:C# Email类的具体用法?C# Email怎么用?C# Email使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Email类属于命名空间,在下文中一共展示了Email类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendEmail
public void SendEmail()
{
Email email = new Email() { To = "[email protected]", Subject = "Unit Test", DeliveryType ="Email", Message = "Test" };
SendMail sendMail = new SendMail();
Assert.IsTrue(sendMail.SendEmail(email));
}
开发者ID:nVisionIT,项目名称:Moved-ProDev-D,代码行数:7,代码来源:EmailTest.cs
示例2: SendEmail
public static void SendEmail(Email email)
{
#if UNITY_IOS && !UNITY_EDITOR
_opencodingConsoleBeginEmail(email.ToAddress, email.Subject, email.Message, email.IsHTML);
foreach (var attachment in email.Attachments)
{
_opencodingConsoleAddAttachment(attachment.Data, attachment.Data.Length, attachment.MimeType, attachment.Filename);
}
_opencodingConsoleFinishEmail();
#elif UNITY_ANDROID && !UNITY_EDITOR
AndroidJavaClass androidEmailClass = new AndroidJavaClass("net.opencoding.console.Email");
androidEmailClass.CallStatic("beginEmail", email.ToAddress, email.Subject, email.Message, email.IsHTML);
var emailAttachmentsDirectory = Path.Combine(Application.temporaryCachePath, "EmailAttachments");
Directory.CreateDirectory(emailAttachmentsDirectory);
foreach (var attachment in email.Attachments)
{
var attachmentPath = Path.Combine(emailAttachmentsDirectory, attachment.Filename);
File.WriteAllBytes(attachmentPath, attachment.Data);
androidEmailClass.CallStatic("addAttachment", attachmentPath);
}
androidEmailClass.CallStatic("finishEmail");
#else
throw new InvalidOperationException("Emailing is not supported on this platform. Please contact [email protected] and I'll do my best to support it!");
#endif
}
开发者ID:smclallen,项目名称:Galactic_Parcel_Service,代码行数:27,代码来源:NativeMethods.cs
示例3: EmailToAccountMapQueryModel
public EmailToAccountMapQueryModel(Email email, Guid accountId)
{
Contract.Argument(() => email, () => accountId).NotNullOrDefault();
Email = email;
AccountId = accountId;
}
开发者ID:RichieYang,项目名称:Composable.Monolithic,代码行数:7,代码来源:EmailToAccountMapQueryModel.cs
示例4: HomeViewModel
public HomeViewModel(ITelephonyService telephonyService = null, IScreen hostScreen = null)
{
TelephonyService = telephonyService ?? Locator.Current.GetService<ITelephonyService>();
HostScreen = hostScreen ?? Locator.Current.GetService<IScreen>();
var canComposeSMS = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
ComposeSMS = ReactiveCommand.CreateAsyncTask(canComposeSMS,
async _ => { await TelephonyService.ComposeSMS(Recipient); });
ComposeSMS.ThrownExceptions.Subscribe(
ex => UserError.Throw("Does this device have the capability to send SMS?", ex));
var canComposeEmail = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
ComposeEmail = ReactiveCommand.CreateAsyncTask(canComposeEmail, async _ =>
{
var email = new Email(Recipient);
await TelephonyService.ComposeEmail(email);
});
ComposeEmail.ThrownExceptions.Subscribe(
ex => UserError.Throw("The recipient is potentially not a well formed email address.", ex));
var canMakePhoneCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
MakePhoneCall = ReactiveCommand.CreateAsyncTask(canMakePhoneCall,
async _ => { await TelephonyService.MakePhoneCall(Recipient); });
MakePhoneCall.ThrownExceptions.Subscribe(
ex => UserError.Throw("Does this device have the capability to make phone calls?", ex));
var canMakeVideoCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
MakeVideoCall = ReactiveCommand.CreateAsyncTask(canMakeVideoCall,
async _ => { await TelephonyService.MakeVideoCall(Recipient); });
MakeVideoCall.ThrownExceptions.Subscribe(
ex => UserError.Throw("Does this device have the capability to make video calls?", ex));
}
开发者ID:Jurabek,项目名称:telephony,代码行数:34,代码来源:HomeViewModel.cs
示例5: MemberReport
/// <summary>
/// Report a member
/// </summary>
/// <param name="report"></param>
public void MemberReport(Report report)
{
var sb = new StringBuilder();
var email = new Email();
sb.AppendFormat("<p>{2}: <a href=\"{0}\">{1}</a></p>",
string.Concat(_settingsService.GetSettings().ForumUrl.TrimEnd('/'), report.Reporter.NiceUrl),
report.Reporter.UserName,
_localizationService.GetResourceString("Report.Reporter"));
sb.AppendFormat("<p>{2}: <a href=\"{0}\">{1}</a></p>",
string.Concat(_settingsService.GetSettings().ForumUrl.TrimEnd('/'), report.ReportedMember.NiceUrl),
report.ReportedMember.UserName,
_localizationService.GetResourceString("Report.MemberReported"));
sb.Append($"<p>{_localizationService.GetResourceString("Report.Reason")}:</p>");
sb.Append($"<p>{report.Reason}</p>");
email.EmailTo = _settingsService.GetSettings().AdminEmailAddress;
email.Subject = _localizationService.GetResourceString("Report.MemberReport");
email.NameTo = _localizationService.GetResourceString("Report.Admin");
email.Body = _emailService.EmailTemplate(email.NameTo, sb.ToString());
_emailService.SendMail(email);
}
开发者ID:lenwen,项目名称:mvcforum,代码行数:29,代码来源:ReportService.cs
示例6: CreateValidWorkEmail
public Email CreateValidWorkEmail()
{
Email email = new Email();
email.Address = "[email protected]";
email.Type = EmailType.Work;
return email;
}
开发者ID:rdammkoehler,项目名称:C-TDDExamples,代码行数:7,代码来源:EmailFixture.cs
示例7: getEmailDataFromTable
private static IEnumerable<Email> getEmailDataFromTable()
{
SqlCommand command = new SqlCommand(
string.Format("SELECT Id as IdMail, EMail as SendTo, Theme as Topic, Text as Body FROM {0} WHERE Sended=0", TABLE_NAME),
connection);
SqlDataReader reader = command.ExecuteReader();
List<Email> newMails = new List<Email>();
while (reader.Read())
{
Email mail = new Email
{
IdMail = reader["IdMail"].ToString().Trim(),
SendTo = reader["SendTo"].ToString().Trim(),
Topic = reader["Topic"].ToString().Trim(),
Body = reader["Body"].ToString().Trim()
};
Console.WriteLine("--- New e-mail ---");
Console.WriteLine("SendTo: " + mail.SendTo);
Console.WriteLine("Topic: " + mail.Topic);
Console.WriteLine("Body: " + mail.Body);
newMails.Add(mail);
}
reader.Close();
return newMails;
}
开发者ID:AramisIT,项目名称:DllExchange,代码行数:29,代码来源:Program.cs
示例8: DoAction
public void DoAction(WFActivity activity)
{
this._activity = activity;
_mail = new Email();
foreach (KeyValuePair<string, WFUser> kvUser in activity.WFUsers)
{
string mailAddress = String.IsNullOrWhiteSpace(kvUser.Value.Email) ? "" : kvUser.Value.Email.Trim() + ";";
if (kvUser.Value.IsKeyUser)
{
toUser += kvUser.Value.DisplayName + ",";
toMail += mailAddress;
}
else if (kvUser.Value.IsApprover && !kvUser.Value.IsKeyUser)
{
continue;
}
else
{
ccMail += mailAddress;
}
}
if (AccessControl.IsVendor())
{
toUser += AccessControl.CurrentLogonUser.Name + ",";
toMail += string.IsNullOrEmpty(AccessControl.CurrentLogonUser.Email) ?
"" : AccessControl.CurrentLogonUser.Email.Trim() + ";";
}
SendMail();
}
开发者ID:rivernli,项目名称:SGP,代码行数:31,代码来源:SendMailAction.cs
示例9: SendEmailAsync
// Methods
public Task SendEmailAsync(Email email)
{
return Task.Run(() =>
{
try
{
MailMessage mail = new MailMessage
{
From = new MailAddress(email.From),
Subject = email.Subject,
Body = email.Body,
IsBodyHtml = true
};
mail.To.Add(email.To);
SmtpClient smtp = new SmtpClient
{
Host = authentication.Host,
Port = authentication.Port,
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential(authentication.UserName, authentication.Password),
EnableSsl = true
};
smtp.Send(mail);
}
catch
{
}
}
);
}
开发者ID:jeddeh,项目名称:grande-travel,代码行数:34,代码来源:DefaultEmailService.cs
示例10: Send
public void Send(Email email)
{
using (var mailMessage = CreateMailMessage(email))
{
_simpleEmailService.SendEmail(CreateSendEmailRequest(mailMessage));
}
}
开发者ID:spatialfiend,项目名称:Postal.AmazonSES,代码行数:7,代码来源:SimpleEmailService.cs
示例11: ValidateModel
public static HttpResponseMessage ValidateModel(Email.Email model)
{
var response = new HttpResponseMessage();
if (!model.DeliveryType.Trim().ToLower().Equals("email"))
{
response.StatusCode = HttpStatusCode.NotImplemented;
response.ReasonPhrase = string.Format("The DeliveryType [{0}] is not implemented.", model.DeliveryType);
Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(new Exception(string.Format("The DeliveryType [{0}] is not implemented.", model.DeliveryType))));
}
if (string.IsNullOrWhiteSpace(model.To))
{
response.ReasonPhrase = "The \"To\" value is required";
response.StatusCode = HttpStatusCode.BadRequest;
}
if (string.IsNullOrWhiteSpace(model.Subject))
{
response.ReasonPhrase = "The \"Subject\" value is required";
response.StatusCode = HttpStatusCode.BadRequest;
}
try
{
var mailAddress = new MailAddress(model.To);
}
catch (FormatException)
{
response.ReasonPhrase = "The \"To\" value is not a valid email address";
response.StatusCode = HttpStatusCode.BadRequest;
}
return response;
}
开发者ID:nVisionIT,项目名称:Moved-ProDev-D,代码行数:33,代码来源:ValidateEmail.cs
示例12: TestMethod1
public void TestMethod1()
{
/*var res = ArticuloLogica.Instancia.ingresarBodega(1, "Bodega San Pedro", "123");
var result = ArticuloLogica.Instancia.obtenerBodegas(1);
var result = ArticuloLogica.Instancia.ingresarArticulo(1, "100213", "Lápices Mongol", "unidad", "Son chinos", Convert.FromBase64String(""), 1);*/
//var res = ArticuloLogica.Instancia.obtenerArticulosBodega("Bodega San Pedro");
var orden = new Documento() {
Fecha1= System.DateTime.Now,
IdSocio = 2,
TipoDocumento = 1,
TotalAI = 1300
};
var detalle = new DocumentoDetalle(){
NumeroDocumento = 22,
IdArticulo = 1,
Cantidad = 10,
Descripcion = "Lapices Mongol",
IdBodega = 1,
Impuesto = 13,
Precio = 130,
TipoDocumento = 1
};
Email email = new Email();
email.EnviarCorreo("[email protected]", orden, detalle);
}
开发者ID:jaalvarez92,项目名称:SIA-Proyecto2,代码行数:26,代码来源:UnitTest1.cs
示例13: Send
public EmailSendAttempt Send(Email email)
{
email.Sender = email.Sender ?? Configuration.EmailSender;
var attempt = new EmailSendAttempt
{
Date = DateTime.UtcNow,
Server = Smtp.Host,
Success = true,
};
try
{
Smtp.Send(email.ToMailMessage());
email.Sent = DateTime.UtcNow;
}
catch (Exception ex)
{
attempt.Success = false;
attempt.Error = ex.Message;
}
email.Tenant = Tenant.Document.Id;
email.AddAttempt(attempt);
Emails.Save(email);
return attempt;
}
开发者ID:nicknystrom,项目名称:AscendRewards,代码行数:25,代码来源:EmailMessagingService.cs
示例14: ValidateEmail
private bool ValidateEmail()
{
var email = new Email(_emailCandidate.Text);
if(String.IsNullOrEmpty(_emailCandidate.Text)) _emailCandidate.SetError(GetString(Resource.String.field_not_fill), _errorDrawable);
if(!email.IsValid ()) _emailCandidate.SetError(GetString(Resource.String.invalid_email), _errorDrawable);
return email.IsValid ();
}
开发者ID:bernardo-bruning,项目名称:AnalysiSkill,代码行数:7,代码来源:CadasterCandidateActivity.cs
示例15: CreateValidAltEmail
public Email CreateValidAltEmail()
{
Email email = new Email();
email.Address = "[email protected]";
email.Type = EmailType.Alt;
return email;
}
开发者ID:rdammkoehler,项目名称:C-TDDExamples,代码行数:7,代码来源:EmailFixture.cs
示例16: Main
static void Main(string[] args)
{
string f = "image/";
IAvatarFolder folder = new AvatarFolder(f);
int width = 250;
IEmail email = new Email("[email protected]");
IAvatarConfiguration configuration =
new AvatarConfiguration(
email,
folder,
width,
AvatarImageExtension.Jpeg,
AvatarRating.R);
IAvatar avatar = new Avatar(configuration);
if (avatar.Exists() == false)
{
avatar.Save();
System.Console.WriteLine("Foto gravada com sucesso !!!");
}
else
{
System.Console.WriteLine("Foto existente !!!");
}
System.Console.ReadKey();
}
开发者ID:netdragoon,项目名称:gravatar,代码行数:33,代码来源:Program.cs
示例17: CreateValidHomeEmail
public Email CreateValidHomeEmail()
{
Email email = new Email();
email.Address = "[email protected]";
email.Type = EmailType.Home;
return email;
}
开发者ID:rdammkoehler,项目名称:C-TDDExamples,代码行数:7,代码来源:EmailFixture.cs
示例18: Post
public Email Post(Email email)
{
try
{
repository.Add(email);
foreach (var file in email.Attachments)
{
if (!string.IsNullOrEmpty(file.Content))
{
if (File.Exists(attachmentSaveFolder + file.Name))
File.Delete(attachmentSaveFolder + file.Name);
byte[] filebytes = Convert.FromBase64String(file.Content);
FileStream fs = new FileStream(attachmentSaveFolder + file.Name,
FileMode.CreateNew,
FileAccess.Write,
FileShare.None);
fs.Write(filebytes, 0, filebytes.Length);
fs.Close();
}
}
return email;
}
catch (HttpRequestException e)
{
// !!!
// HttpResponseExceptions are not properly returned yet. It's a known bug in WCF WebAPI preview 6. I'm hoping it's fixed in a subsequent release.
// !!!
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(e.InnerException.ToString()) });
}
}
开发者ID:jptoto,项目名称:postmark-inbound-demo,代码行数:32,代码来源:PostmarkApi.cs
示例19: Create
public ActionResult Create(PFModel model)
{
try
{
PF pfData = new PF();
int idPF = pfData.Inserir(model);
List<EmailModel> listaEmail = new List<EmailModel>();
if (Session["EmailPF"] != null)
listaEmail = (List<EmailModel>)Session["EmailPF"];
List<TelefoneModel> listaTelefone = new List<TelefoneModel>();
if (Session["TelefonePF"] != null)
listaTelefone = (List<TelefoneModel>)Session["TelefonePF"];
List<EnderecoModel> listaEndereco = new List<EnderecoModel>();
if (Session["EnderecoPF"] != null)
listaEndereco = (List<EnderecoModel>)Session["EnderecoPF"];
List<PF_PJModel> listaEmpresa = new List<PF_PJModel>();
if (Session["EmpresaPF"] != null)
listaEmpresa = (List<PF_PJModel>)Session["EmpresaPF"];
Email _dataEmail = new Email();
foreach (EmailModel item in listaEmail)
{
item.IdPessoa = idPF;
_dataEmail.Inserir(item);
}
Telefone _dataTel = new Telefone();
foreach (TelefoneModel item in listaTelefone)
{
item.IdPessoa = idPF;
_dataTel.Inserir(item);
}
Endereco _dataEndereco = new Endereco();
foreach (EnderecoModel item in listaEndereco)
{
item.IdPessoa = idPF;
_dataEndereco.Inserir(item);
}
foreach (PF_PJModel item in listaEmpresa)
{
pfData.InsereEmpresa(idPF, item.PJ.Id, item.Cargo.Id, item.Departamento.Id);
}
Session["EnderecoPF"] = null;
Session["TelefonePF"] = null;
Session["EmailPF"] = null;
return RedirectToAction("Index");
}
catch
{
return View();
}
}
开发者ID:Marksys,项目名称:CAD,代码行数:60,代码来源:CadastroPFController.cs
示例20: SendContactMessage
public bool SendContactMessage(string name , string email, string phone, string location, string message)
{
string path = HttpContext.Current.Server.MapPath("~" + ConfigurationManager.AppSettings["savedmessagepath"] +
String.Format("{0:s}", DateTime.Now).Replace('T', '_').Replace(':', '-') + ".txt");
try
{
StringBuilder sbBody = new StringBuilder();
sbBody.Append(" Dear Admin," + Environment.NewLine);
sbBody.Append(string.Format("A user with the following name {0}, number {1} and location {2}." + Environment.NewLine, name, phone, location));
sbBody.Append("Has sent the following message." + Environment.NewLine);
sbBody.Append("----------------------------------------------------------------" + Environment.NewLine + message + Environment.NewLine);
//persist message in file
using (TextWriter writer = File.CreateText(path))
{
writer.WriteLine(sbBody.ToString());
}
Email mail = new Email(EmailConstants.SMTPServer, EmailConstants.AdminEmail, EmailConstants.AdminPass);
return mail.send_html(EmailConstants.AdminEmail, EmailConstants.AdminName, email, name, "[Global Service Security] - New Enquriy", sbBody.ToString());
}
catch(Exception ex) {
using (TextWriter writer = File.CreateText(path))
{
writer.WriteLine("Email sent failed." + ex.Message);
}
return false;
}
}
开发者ID:Cmadmin,项目名称:globalservicesecurity.com,代码行数:33,代码来源:MessagingService.cs
注:本文中的Email类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论