本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Application类的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Outlook.Application类的具体用法?C# Microsoft.Office.Interop.Outlook.Application怎么用?C# Microsoft.Office.Interop.Outlook.Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microsoft.Office.Interop.Outlook.Application类属于命名空间,在下文中一共展示了Microsoft.Office.Interop.Outlook.Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: object
private static readonly object _lock = new object(); // Sync the processing of items in the Outbox
public OutboxMonitor(Microsoft.Office.Interop.Outlook.Application application)
{
try
{
_application = application;
_ns = _application.GetNamespace("MAPI");
_outbox = _ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
_items = _outbox.Items;
_items.ItemAdd += Items_ItemAdd;
SubmitNonDeferredItems();
SyncroniseDeferredSendStore();
CreateSubmitWorkerThreads();
Logger.LogInfo("Secure File Transfer Outbox monitor created and configured.");
}
catch (Exception ex)
{
Dispose();
Logger.LogError(ex);
Logger.LogError("Failed to create OutboxMonitor. Disable DeferredSend");
throw;
}
}
示例2: OutlookPortal
public OutlookPortal()
{
oApp = new Microsoft.Office.Interop.Outlook.Application();
oNameSpace = oApp.GetNamespace("MAPI");
oOutboxFolder = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
oNameSpace.Logon(null, null, false, false);
oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
}
示例3: Initialize
protected override void Initialize() {
base.Initialize();
this.Application = this.GetHostItem<Microsoft.Office.Interop.Outlook.Application>(typeof(Microsoft.Office.Interop.Outlook.Application), "Application");
Globals.ThisAddIn = this;
global::System.Windows.Forms.Application.EnableVisualStyles();
this.InitializeCachedData();
this.InitializeControls();
this.InitializeComponents();
this.InitializeData();
}
示例4: GetAllEvents
/// <summary>
/// Gets a list of all events in outlook
/// </summary>
public static List<CalendarEvent> GetAllEvents()
{
List<CalendarEvent> events = new List<CalendarEvent>();
Microsoft.Office.Interop.Outlook.Application oApp = null;
Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;
Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null;
Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null;
oApp = new Microsoft.Office.Interop.Outlook.Application();
mapiNamespace = oApp.GetNamespace("MAPI");
CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); outlookCalendarItems = CalendarFolder.Items;
outlookCalendarItems.IncludeRecurrences = true;
CalendarEvent cEvent = null;
foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
{
cEvent = null;
if (item.IsRecurring)
{
Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
DateTime last = new DateTime(2008, 10, 1);
Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;
for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
{
try
{
recur = rp.GetOccurrence(cur);
cEvent = new CalendarEvent(recur.GlobalAppointmentID, recur.Start, recur.End, recur.Location, recur.Subject, recur.Body);
}
catch
{ }
}
}
else
{
cEvent = new CalendarEvent(item.GlobalAppointmentID, item.Start, item.End, item.Location, item.Subject, item.Body);
}
if (cEvent != null)
events.Add(cEvent);
}
return events;
}
示例5: Initialize
public void Initialize() {
this.HostItemHost = ((Microsoft.VisualStudio.Tools.Applications.Runtime.IHostItemProvider)(this.RuntimeCallback.GetService(typeof(Microsoft.VisualStudio.Tools.Applications.Runtime.IHostItemProvider))));
this.DataHost = ((Microsoft.VisualStudio.Tools.Applications.Runtime.ICachedDataProvider)(this.RuntimeCallback.GetService(typeof(Microsoft.VisualStudio.Tools.Applications.Runtime.ICachedDataProvider))));
object hostObject = null;
this.HostItemHost.GetHostObject("Microsoft.Office.Interop.Outlook.Application", "Application", out hostObject);
this.Application = ((Microsoft.Office.Interop.Outlook.Application)(hostObject));
Globals.ThisAddIn = this;
System.Windows.Forms.Application.EnableVisualStyles();
this.InitializeCachedData();
this.InitializeControls();
this.InitializeComponents();
this.InitializeData();
this.BeginInitialization();
}
示例6: Calendar
public Calendar(int Days, List<String> EMails, String path, String ID)
{
sendEmail = false;
objEntryID = ID;
_Days = Days;
_EMails = EMails;
EmailEvents = new List<EmailEvent>();
// set log path from logPath constant from Main()
LOGPATH = path;
#if Debug
try
{
#endif
objOutlook = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace objNS = objOutlook.GetNamespace("MAPI");
//objEntryID = "000000005BCDA19FC3AF564C9A7D910BCCF3D24642820000";
//String objEntryID = "00000000E6BD34CD1C0FA04DBA1773A312FE25690100E15948BC84BC624E822DC6493E0F48BE0010CCEC4D970000";
objCalendar = objOutlook.Session.GetFolderFromID(objEntryID, System.Type.Missing);
#if Debug
}
catch (Exception ex)
{
//ToDo:
// add handling for exception accessing Outlook
System.IO.File.AppendAllText(LOGPATH,DateTime.Now.ToString() + ": " + ex.Message + Environment.NewLine);
return;
}
#endif
findEvents();
}
示例7: Parser
public Parser(string file, bool? test, IEmailManager emailManager,
IStudentManager studentManager)
{
try
{
_excelFactory = new ExcelQueryFactory(file);
}
catch (IOException e)
{
throw;
}
_emailManager = emailManager;
_studentManager = studentManager;
_students = new Dictionary<string, Domain.Student>();
_myOutlook = new Application();
_isTest = test;
_studentTask = Task.Factory.StartNew(PopulateStudents);
}
示例8: OutlookMail
/// <summary>
/// Constructor
/// </summary>
public OutlookMail()
{
//Return a reference to the MAPI layer
oApp = new Microsoft.Office.Interop.Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
/***********************************************************************
* Logs on the user
* Profile: Set to null if using the currently logged on user, or set
* to an empty string ("") if you wish to use the default Outlook Profile.
* Password: Set to null if using the currently logged on user, or set
* to an empty string ("") if you wish to use the default Outlook Profile
* password.
* ShowDialog: Set to True to display the Outlook Profile dialog box.
* NewSession: Set to True to start a new session. Set to False to
* use the current session.
***********************************************************************/
oNameSpace.Logon(null,null,true,true);
//gets defaultfolder for my Outlook Outbox
oSentItems = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);
}
示例9: GetContent
public List<outlookProperty> GetContent(DateTime DateFrom, DateTime DateTo)
{
string strContent="";
string strSubject="";
DateTime MailDate;
//string strFrom;
string strTo="";
List<outlookProperty> result = new List<outlookProperty>();
var app = new Microsoft.Office.Interop.Outlook.Application();
var nameSpace = app.GetNamespace("MAPI");
var inboxFolder = nameSpace.Folders["[email protected]"].Folders["Inbox"].Folders["MEC"];
int intTopiterator = inboxFolder.Items.Count;
var mailItems = inboxFolder.Items;
//foreach (Microsoft.Office.Interop.Outlook.MailItem mailItem in inboxFolder.Items)
for (int i = 1; i <= intTopiterator;i++ )
{
//strTo = mailItems[1];
strSubject = mailItems[i].Subject.ToString();
strContent = mailItems[i].Body.ToString();
MailDate = mailItems[i].CreationTime.Date;
//strFrom=mailItem.f
//if (mailItem.To.ToString() != null)
//{
// strTo = mailItem.To.ToString();
//}
//else
//{
// strTo = "";
//}
if (MailDate >= DateFrom && MailDate <= DateTo)
{
result.Add(new outlookProperty() { strSubject = strSubject, strContent = strContent, CreationDate = MailDate, strFrom = "", strTo = "" });
}
}
return result;
}
示例10: OpenOutlookMail
public static void OpenOutlookMail(string outlookLink)
{
outlookLink = outlookLink.Substring(8);
try
{
Microsoft.Office.Interop.Outlook.Application app;
Microsoft.Office.Interop.Outlook._NameSpace ns;
app = new Microsoft.Office.Interop.Outlook.Application();
ns = app.GetNamespace("MAPI");
ns.Logon(null, null, false, false);
Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem)
ns.GetItemFromID(outlookLink);
mailItem.Display();
}
catch (Exception ex)
{
}
}
示例11: sendMessage
private bool sendMessage(string from, string to, string subject, string content)
{
try
{
Microsoft.Office.Interop.Outlook.Application outlook =
new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem)
outlook.CreateItem(Microsoft.Office.Interop.Outlook
.OlItemType.olMailItem);
mailItem.Subject = subject;
mailItem.To = to;
mailItem.HTMLBody = content;
mailItem.Importance = important ?
Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh
: Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;
mailItem.BodyFormat = Microsoft.Office.Interop.Outlook
.OlBodyFormat.olFormatHTML;
mailItem.Display(false);
mailItem.Send();
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
示例12: DoWork
internal static Status DoWork(DateTime date, bool reallyDoWork = false)
{
try
{
if (reallyDoWork == false) //avoid contacting outlook server in this case
{
var s = (from l in ListStatus
where l.Date == date.DateTimeToString()
select l).FirstOrDefault();
if (s != null)
{
return s;
}
else
{
return new Status(date);
}
}
lock (_doOutlookWorkSync)
{
Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace objNsp = objApp.GetNamespace("MAPI");
//objNsp.Logon("yahara\test", "test1234", false, true);
//Microsoft.Office.Interop.Outlook.Application objApp = GetApplicationObject();
//Microsoft.Office.Interop.Outlook.NameSpace objNsp = objApp.GetNamespace("MAPI");
Status s1 = null;
Status s2 = null;
Status final = null;
//mail
Microsoft.Office.Interop.Outlook.MAPIFolder objMAPIFolder = objNsp.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
// Set recepient
Microsoft.Office.Interop.Outlook.Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)objNsp.CreateRecipient("[email protected]");
// Get calendar folder
Microsoft.Office.Interop.Outlook.MAPIFolder calendarFolder = objNsp.GetSharedDefaultFolder(oRecip, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
if (ListStatus == null || ListStatus.Count == 0) // first call
{
ListStatus = new List<Status>(NumberOfPastDaysToCache + NumberOfFutureDaysToCache);
for (int i = -1 * NumberOfFutureDaysToCache; i < NumberOfPastDaysToCache + NumberOfFutureDaysToCache; i++)
{
DateTime specificDate = date.AddDays(-1 * i);
Debug.WriteLine("i=" + i.ToString() + " & specificDate=" + specificDate.DateTimeToString());
try
{
s1 = DownloadStatusForDate(specificDate, objMAPIFolder);
s2 = DownloadMeetingsForDate(specificDate, calendarFolder);
final = new Status(s1.Date.StringToDateTime());
if (s1 != null && s1.ListOfItems != null && s1.ListOfItems.Count > 0)
final.ListOfItems.AddRange(s1.ListOfItems);
if (s2 != null && s2.ListOfItems != null && s2.ListOfItems.Count > 0)
final.ListOfItems.AddRange(s2.ListOfItems);
ListStatus.Add(final);
}
catch
{
ListStatus.Add(new Status(specificDate));
;//swallow and move on
}
}
}
else
{
try
{
s1 = DownloadStatusForDate(DateTime.Today, objMAPIFolder);
s2 = DownloadMeetingsForDate(DateTime.Today, calendarFolder);
final = new Status(s1.Date.StringToDateTime());
if (s1 != null && s1.ListOfItems != null && s1.ListOfItems.Count > 0)
final.ListOfItems.AddRange(s1.ListOfItems);
if (s2 != null && s2.ListOfItems != null && s2.ListOfItems.Count > 0)
final.ListOfItems.AddRange(s2.ListOfItems);
//find and remove stale entry
var s = (from l in ListStatus
where l.Date == DateTime.Today.DateTimeToString()
select l).FirstOrDefault();
if (s != null)
ListStatus.Remove(s);
//add fresh entry
ListStatus.Add(final);
}
catch
{
;//swallow and move on
}
}
if (calendarFolder != null)
{
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(calendarFolder);
//.........这里部分代码省略.........
示例13: timer_CntDwn_Tick
private void timer_CntDwn_Tick(object sender, EventArgs e)
{
if ((cntDown < 55) && (subContent.Length == 0))
{
this.richTextBox1.Text = String.Format("No data to send at {0} (cancelled)", DateTime.Now.ToString());
this.timer_CntDwn.Enabled = false;
File.WriteAllText(tmpFile, subContent); // avoid a re-trigger in 5 minutes.
}
else if (cntDown > 0)
{
this.richTextBox1.Text = String.Format("Sending in {0} seconds:\n{1}", cntDown, subContent);
cntDown--;
switch (cntDown)
{
case 59:
//case 54:
//case 44:
this.Show();
this.WindowState = FormWindowState.Normal;
this.TopMost = true;
this.CenterToScreen();
this.TopMost = false;
break;
}
}
else
{
this.richTextBox1.Text = String.Format("Sent at {0}:\n{1}", DateTime.Now.ToString(), subContent);
string emailTo = this.textBox_eMail.Text;
string originalValue = MyKepiCrawler.Properties.Settings.Default.Properties["MySendEmail"].DefaultValue as string;
if (emailTo == originalValue)
emailTo = "";
try
{
File.WriteAllText(tmpFile, subContent);
if (emailTo.Length > 3)
{
string bodyEmail = subContent;
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem eMail = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
eMail.Subject = "Kepi Update V1";
eMail.To = emailTo;
eMail.Body = bodyEmail;
((Microsoft.Office.Interop.Outlook._MailItem)eMail).Send();
}
}
catch (Exception ex)
{
string errMsg = String.Format("Error sending 'Kepi Update' Email: {0} at {1}:\n{2}", ex.Message, DateTime.Now.ToString(), subContent);
this.richTextBox1.Text = errMsg;
File.WriteAllText(tmpFile, errMsg);
}
finally
{
this.timer_CntDwn.Enabled = false;
}
}
Properties.Settings.Default.MySearchString = this.textBox2.Text;
Properties.Settings.Default.MySendEmail = this.textBox_eMail.Text;
Properties.Settings.Default.Save();
}
示例14: buttonGenerate_Click
//.........这里部分代码省略.........
sb.AppendFormat("<a href='{0}'>{1}</a>: {2}</td>",
HttpUtility.UrlEncode(groupArtifact.Url),
groupArtifact.FormattedID,
HttpUtility.HtmlEncode(groupArtifact.Name)
);
sb.AppendFormat("</td>");
var addTr = false;
foreach (var change in group)
{
var artifact = change.Artifact;
if (addTr)
{
sb.AppendLine("<tr>");
}
sb.AppendLine("<td class='task-col'>");
sb.AppendFormat("<a href='{0}'>{1}</a>: {2}", artifact.Url, artifact.FormattedID, HttpUtility.HtmlEncode(artifact.Name));
sb.AppendLine();
if (artifact.Parent != null && artifact.Parent.Type == ArtifactType.Defect)
{
sb.AppendLine("<br/>");
sb.AppendLine("of defect:<br/>");
sb.AppendFormat("<a href='{0}'>{1}</a>: {2}", artifact.Parent.Url, artifact.Parent.FormattedID, HttpUtility.HtmlEncode(artifact.Parent.Name));
sb.AppendLine();
}
sb.AppendLine("</td>");
sb.AppendLine("<td class='state-col' align=center>");
var state = Artifact.TryGetMember<string>(change.RawArtifact, "State");
if(state == "Completed")
{
sb.AppendLine("Completed");
}
else if(state == "Defined")
{
}
else if (state == "In-Progress")
{
if (change.Change.Estimate > 0 && change.Change.ToDo > 0)
{
var done = (int)(100 * (change.Change.Estimate - change.Change.ToDo) / change.Change.Estimate);
if (done > 0)
{
sb.AppendFormat("{0}%<br/>", done);
sb.AppendFormat(@"
<table style='width: 100px; border-collapse: collapse; table-layout: fixed;' >
<tr style='padding: 0px;'>
<td style='width: {0}px; background-color: lightgreen; padding: 0px; font-size: 50%;'> </td>
<td style='width: {1}px; background-color: gray padding: 0px; font-size: 50%;'> </td>
</tr>
</table>
", done, 100 - done);
}
}
else
{
sb.AppendLine("In Progress");
}
}
else
{
sb.AppendLine(state);
}
sb.AppendLine("</td>");
var c = GetHtmlDescriptiveChanges(change.Change);
sb.AppendFormat("<td class='notes-col'>{0}</td>", c);
sb.AppendLine("</tr>");
addTr = true;
}
}
sb.AppendLine("</TABLE>");
var body = sb.ToString();
var app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem msg;
if (!string.IsNullOrWhiteSpace(Settings.Default.DailyReportTemplatePath))
{
msg = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItemFromTemplate(Settings.Default.DailyReportTemplatePath);
msg.HTMLBody = BuildMailBody(body, msg.HTMLBody);
}
else
{
msg = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
msg.Subject = "Daily Report";
msg.HTMLBody = BuildMailBody(body);
}
msg.Display();
Clipboard.SetText(sb.ToString());
}
示例15: ExportActionToOutlook
public static bool ExportActionToOutlook(Page page, Neos.Data.Action action)
{
string message = string.Empty;
try
{
//First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object:
Microsoft.Office.Interop.Outlook.Application outlookApp =
new Microsoft.Office.Interop.Outlook.Application();
//Next, create an instance of AppointmentItem object and set the properties:
Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment =
(Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApp.CreateItem(
Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
oAppointment.Subject = action.TypeActionLabel + "-" + action.CompanyName + "-" + action.CandidateFullName;
oAppointment.Body = action.DescrAction;
oAppointment.Location = action.LieuRDV;
// Set the start date
//if(action.DateAction.HasValue)
// oAppointment.Start = action.DateAction.Value;
// End date
if (action.Hour.HasValue)
{
oAppointment.Start = action.Hour.Value;
}
// Set the reminder 15 minutes before start
oAppointment.ReminderSet = true;
oAppointment.ReminderMinutesBeforeStart = 15;
//Setting the sound file for a reminder:
oAppointment.ReminderPlaySound = true;
//set ReminderSoundFile to a filename.
//Setting the importance:
//use OlImportance enum to set the importance to low, medium or high
oAppointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
/* OlBusyStatus is enum with following values:
olBusy
olFree
olOutOfOffice
olTentative
*/
oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
//Finally, save the appointment:
// Save the appointment
//oAppointment.Save();
// When you call the Save () method, the appointment is saved in Outlook.
//string recipientsMail = string.Empty;
//foreach (ListItem item in listEmail.Items)
//{
// if (recipientsMail == string.Empty)
// {
// recipientsMail += item.Value;
// }
// else
// {
// recipientsMail += "; " + item.Value;
// }
//}
if (action.ContactID.HasValue)
{
string emailContact = string.Empty;
List<CompanyContactTelephone> contactInfoList =
new CompanyContactTelephoneRepository().GetContactInfo(action.ContactID.Value);
foreach (CompanyContactTelephone item in contactInfoList)
{
if (item.Type == "E")
{
emailContact = item.Tel;
break;
}
}
//ParamUser currentUser = SessionManager.CurrentUser;
if (!string.IsNullOrEmpty(emailContact))
{
//oAppointment.RequiredAttendees = "[email protected]";
//oAppointment.OptionalAttendees = "[email protected]";
// Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email.
Microsoft.Office.Interop.Outlook.MailItem mailItem = oAppointment.ForwardAsVcal();
mailItem.To = emailContact;
mailItem.Send();
//oAppointment.Send();
}
else
{
message = ResourceManager.GetString("messageExportActionNotHaveEmail");
}
}
}
catch (System.Exception ex)
{
message = ex.Message;
}
if (message != string.Empty)
//.........这里部分代码省略.........