本文整理汇总了C#中MailMessage.AddAlternateView方法的典型用法代码示例。如果您正苦于以下问题:C# MailMessage.AddAlternateView方法的具体用法?C# MailMessage.AddAlternateView怎么用?C# MailMessage.AddAlternateView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailMessage
的用法示例。
在下文中一共展示了MailMessage.AddAlternateView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_SMTP();
string dstEmail = dataDir + "outputAttachments.msg";
// Create an instance of the MailMessage class
MailMessage msg = new MailMessage();
// Set the sender, recipient, who will receive the meeting request. Basically, the recipient is the same as the meeting attendees
msg.From = "[email protected]";
msg.To = "[email protected], [email protected], [email protected], [email protected]";
// Create Appointment instance
Appointment app = new Appointment("Room 112", new DateTime(2015, 7, 17, 13, 0, 0), new DateTime(2015, 7, 17, 14, 0, 0), msg.From, msg.To);
app.Summary = "Release Meetting";
app.Description = "Discuss for the next release";
// Add appointment to the message and Create an instance of SmtpClient class
msg.AddAlternateView(app.RequestApointment());
SmtpClient client = GetSmtpClient();
try
{
// Client.Send will send this message
client.Send(msg);
Console.WriteLine("Message sent");
}
catch (Exception ex)
{
Trace.WriteLine(ex.ToString());
}
Console.WriteLine(Environment.NewLine + "Meeting request send successfully.");
}
示例2: Main
static void Main(string[] args)
{
// Create attendees of the meeting
MailAddressCollection attendees = new MailAddressCollection();
attendees.Add("[email protected]");
attendees.Add("[email protected]");
// Set up appointment
Appointment app = new Appointment(
"Location", // location of meeting
DateTime.Now, // start date
DateTime.Now.AddHours(1), // end date
new MailAddress("[email protected]"), // organizer
attendees); // attendees
// Set up message that needs to be sent
MailMessage msg = new MailMessage();
msg.From = "[email protected]";
msg.To = "[email protected]";
msg.Subject = "appointment request";
msg.Body = "you are invited";
// Add meeting request to the message
msg.AddAlternateView(app.RequestApointment());
// Set up the SMTP client to send email with meeting request
SmtpClient client = new SmtpClient("host", 25, "user", "password");
client.Send(msg);
}
示例3: SendEmail
private void SendEmail()
{
try
{
// Build message
MailMessage msg = new MailMessage();
msg.From = txtFrom.Text;
// add recipients
msg.To = txtTo.Text;
msg.Subject = txtSubject.Text;
msg.TextBody = txtTextBody.Text;
// build meeting request
Appointment app = new Appointment(
txtLocation.Text, // location
txtSummary.Text, // summary
txtDescription.Text, // description
DateTime.Parse(txtStartDate.Text + " " + txtStartTime.Text), // start date/time
DateTime.Parse(txtEndDate.Text + " " + txtEndTime.Text), // end date/time
new MailAddress(txtFrom.Text), // organizer
msg.To); // attendees
// attach meeting request to the message
msg.AddAlternateView(app.RequestApointment());
// Send message
SmtpClient smtp = new SmtpClient(
txtHost.Text,
int.Parse(txtPort.Text),
txtUsername.Text,
txtPassword.Text);
// SSL settings
if (chSSL.Checked == true)
{
smtp.EnableSsl = true;
smtp.SecurityMode = SmtpSslSecurityMode.Explicit;
}
smtp.Send(msg);
// show message on screen that email has been sent
lblMessage.ForeColor = System.Drawing.Color.Green;
lblMessage.Text = "Meeting request sent successfully in email.<br><hr>";
}
catch (Exception ex)
{
// display error message
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "Error: " + ex.Message + "<br><hr>";
}
}
示例4: Run
public static void Run()
{
// ExStart:AddAudioReminderToCalendar
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Outlook();
Appointment app = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "[email protected]", "[email protected]");
MailMessage msg = new MailMessage();
msg.AddAlternateView(app.RequestApointment());
MapiMessage mapi = MapiMessage.FromMailMessage(msg);
MapiCalendar calendar = (MapiCalendar)mapi.ToMapiMessageItem();
// Set calendar properties
calendar.ReminderSet = true;
calendar.ReminderDelta = 58;//58 min before start of event
calendar.ReminderFileParameter = dataDir + "Alarm01.wav";
string savedFile = (dataDir + "calendarWithAudioReminder_out.ics");
calendar.Save(savedFile, AppointmentSaveFormat.Ics);
// ExEnd:AddAudioReminderToCalendar
}
示例5: Run
public static void Run()
{
// ExStart:SendMeetingRequestsUsingExchangeServer
try
{
string mailboxUri = @"https://ex07sp1/exchange/administrator"; // WebDAV
string domain = @"litwareinc.com";
string username = @"administrator";
string password = @"Evaluation1";
NetworkCredential credential = new NetworkCredential(username, password, domain);
Console.WriteLine("Connecting to Exchange server.....");
// Connect to Exchange Server
ExchangeClient client = new ExchangeClient(mailboxUri, credential); // WebDAV
// Create the meeting request
Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "[email protected]" + domain, "[email protected]" + domain);
app.Summary = "meeting request summary";
app.Description = "description";
// Create the message and set the meeting request
MailMessage msg = new MailMessage();
msg.From = "[email protected]" + domain;
msg.To = "[email protected]" + domain;
msg.IsBodyHtml = true;
msg.HtmlBody = "<h3>HTML Heading</h3><p>Email Message detail</p>";
msg.Subject = "meeting request";
msg.AddAlternateView(app.RequestApointment(0));
// Send the appointment
client.Send(msg);
Console.WriteLine("Appointment request sent");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// ExEnd:SendMeetingRequestsUsingExchangeServer
}
开发者ID:aspose-email,项目名称:Aspose.Email-for-.NET,代码行数:39,代码来源:SendMeetingRequestsUsingExchangeServer.cs
示例6: Run
public static void Run()
{
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Email();
string dstDraft = dataDir + "appointment-draft_out.msg";
string sender = "[email protected]";
string recipient = "[email protected]";
MailMessage message = new MailMessage(sender, recipient, string.Empty, string.Empty);
Appointment app = new Appointment(string.Empty, DateTime.Now, DateTime.Now, sender, recipient);
app.Method = AppointmentMethodType.Publish;
message.AddAlternateView(app.RequestApointment());
MapiMessage msg = MapiMessage.FromMailMessage(message);
// Save the appointment as draft.
msg.Save(dstDraft);
Console.WriteLine(Environment.NewLine + "Draft saved at " + dstDraft);
}
示例7: Run
public static void Run()
{
// ExStart:SendMeetingRequestsUsingEWS
try
{
// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
// Create the meeting request
Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "[email protected]", "[email protected]");
app.Summary = "meeting request summary";
app.Description = "description";
Aspose.Email.Recurrences.RecurrencePattern pattern = new Recurrences.DailyRecurrencePattern(DateTime.Now.AddDays(5));
app.Recurrence = pattern;
// Create the message and set the meeting request
MailMessage msg = new MailMessage();
msg.From = "[email protected]";
msg.To = "[email protected]";
msg.IsBodyHtml = true;
msg.HtmlBody = "<h3>HTML Heading</h3><p>Email Message detail</p>";
msg.Subject = "meeting request";
msg.AddAlternateView(app.RequestApointment(0));
// send the appointment
client.Send(msg);
Console.WriteLine("Appointment request sent");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// ExEnd:SendMeetingRequestsUsingEWS
}