本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Application类的典型用法代码示例。如果您正苦于以下问题:C# Application类的具体用法?C# Application怎么用?C# Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于Microsoft.Office.Interop.Outlook命名空间,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, RibbonControlEventArgs e)
{
Outlook.Application application = new Outlook.Application();
Outlook.NameSpace ns = application.GetNamespace("MAPI");
try
{
//get selected mail item
Object selectedObject = application.ActiveExplorer().Selection[1];
Outlook.MailItem selectedMail = (Outlook.MailItem)selectedObject;
//create message
Outlook.MailItem newMail = application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
newMail.Recipients.Add(ReadFile());
newMail.Subject = "SPAM";
newMail.Attachments.Add(selectedMail, Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem);
newMail.Send();
selectedMail.Delete();
System.Windows.Forms.MessageBox.Show("Spam notification has been sent.");
}
catch
{
System.Windows.Forms.MessageBox.Show("You must select a message to report.");
}
}
示例2: Main
public static void Main(string[] args)
{
Outlook.Application application = null;
application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
application = new Outlook.Application();
Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
Outlook.MAPIFolder userFolder = null;
Outlook.MAPIFolder emailFolder = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
try
{
foreach (Outlook.MailItem item in emailFolder.Items)
{
if (SearchAttachments(item.Attachments, args[0]))
{
Console.WriteLine(item.Subject);
break;
}
}
}
catch (Exception message)
{
Console.WriteLine(message);
}
}
示例3: CreateRecurringAppointment
private void CreateRecurringAppointment()
{
Outlook.Application outlookApp = new Outlook.Application();
try
{
Outlook.AppointmentItem appt = outlookApp.CreateItem(
Outlook.OlItemType.olAppointmentItem)
as Outlook.AppointmentItem;
appt.Subject = "Customer Review";
appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
appt.Location = "36/2021";
appt.Start = DateTime.Parse("10/20/2006 10:00 AM");
appt.End = DateTime.Parse("10/20/2006 11:00 AM");
appt.Body = "Testing";
Outlook.Recipient recipRequired =
appt.Recipients.Add("Ryan Gregg");
recipRequired.Type =
(int)Outlook.OlMeetingRecipientType.olRequired;
Outlook.Recipient recipOptional =
appt.Recipients.Add("Peter Allenspach");
recipOptional.Type =
(int)Outlook.OlMeetingRecipientType.olOptional;
Outlook.Recipient recipConf =
appt.Recipients.Add("Conf Room 36/2021 (14) AV");
recipConf.Type =
(int)Outlook.OlMeetingRecipientType.olResource;
appt.Recipients.ResolveAll();
appt.Display(false);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show("The following error occurred: " + ex.Message);
}
}
示例4: Page_PreRender
protected void Page_PreRender(object sender, EventArgs e)
{
OutLook._Application outlookObj = new OutLook.Application();
//Button btnPlaySong = (Button) this.form.FindControl("btnPlaySong");
//Song.rr = Request.PhysicalApplicationPath.ToString();
}
示例5: OLCalReader
public OLCalReader(String profileName)
{
myOutlook = new Outlook.Application ();
myProfile = myOutlook.Session;
this.profileName = profileName;
Logon ();
}
示例6: CreateOutlookEmail
}//end of Email Method
public static void CreateOutlookEmail(List<string> toList, string subject, string msg, string attachementFileName = null)
{
try
{
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = subject;
Outlook.Recipients oRecips = mailItem.Recipients;
if (toList != null)
{
foreach (var i in toList)
{
Outlook.Recipient oRecip = oRecips.Add(i);
oRecip.Resolve();
}
}
if (attachementFileName != null)
{
//int iPosition = (int) mailItem.Body.Length + 1;
//int iAttachType = (int) Outlook.OlAttachmentType.olByValue;
//now attached the file
mailItem.Attachments.Add(attachementFileName);
}
mailItem.HTMLBody += msg;
mailItem.Display(true);
}
catch (Exception eX)
{
throw new Exception("cDocument: Error occurred trying to Create an Outlook Email"
+ Environment.NewLine + eX.Message);
}
}
示例7: ThisAddIn_Startup
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Microsoft.Office.Interop.Outlook._Application OutlookObject = new Microsoft.Office.Interop.Outlook.Application();
//Create a new Contact Item
Microsoft.Office.Interop.Outlook.ContactItem contact = OutlookObject.CreateItem(
Microsoft.Office.Interop.Outlook.OlItemType.olContactItem);
//Set different properties of this Contact Item.
contact.FirstName = "Mellissa";
contact.LastName = "MacBeth";
contact.JobTitle = "Account Representative";
contact.CompanyName = "Contoso Ltd.";
contact.OfficeLocation = "36/2529";
contact.BusinessTelephoneNumber = "4255551212 x432";
contact.BusinessAddressStreet = "1 Microsoft Way";
contact.BusinessAddressCity = "Redmond";
contact.BusinessAddressState = "WA";
contact.BusinessAddressPostalCode = "98052";
contact.BusinessAddressCountry = "United States of America";
contact.Email1Address = "[email protected]";
contact.Email1AddressType = "SMTP";
contact.Email1DisplayName = "Melissa MacBeth ([email protected])";
//Save the Contact to disc
contact.SaveAs("OutlookContact.vcf", OlSaveAsType.olVCard);
}
示例8: InitializeObjects
private void InitializeObjects()
{
_myApp = new Microsoft.Office.Interop.Outlook.Application();
_mapiNameSpace = _myApp.GetNamespace("MAPI");
_mapiFolder = _mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
}
示例9: ThisAddIn_Startup
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
OutlookApplication = Application as Outlook.Application;
OutlookInspectors = OutlookApplication.Inspectors;
OutlookInspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(OutlookInspectors_NewInspector);
OutlookApplication.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(OutlookApplication_ItemSend);
}
示例10: SettingsManager
public SettingsManager(Outlook.Application app)
{
Application = app;
this.profile = Application.Session.CurrentProfileName;
Outlook.Folder oInbox = (Outlook.Folder)Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
this.storage = oInbox.GetStorage("calcifyStore", Outlook.OlStorageIdentifierType.olIdentifyBySubject);
}
示例11: Initialise
public Microsoft.Office.Interop.Outlook.Application Initialise()
{
if (!MapiProfileHelperIsRegistered())
{
RegisterMapiProfileHelper();
{
if (!MapiProfileHelperIsRegistered())
throw new System.Exception("You need to register the MapiProfileHelper for these tests to run.");
}
}
m_bOutlookWasRunningBeforeSenderStarted = IsOutlookRuuning();
HideOutlookLogonProfileDialog();
SetMailProfile();
try
{
m_outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
}
catch (COMException)
{
Thread.Sleep(2000); // Outlook 2010 seems twitchy and can respond with an error indicating its not ready - wait and try again
m_outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
}
return m_outlookApplication;
}
示例12: SendEMailThroughOutlook
public static void SendEMailThroughOutlook(List<string> toList, string subject, string msg, string attachementFileName = null )
{
// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
// Set HTMLBody.
//add the body of the email
oMsg.HTMLBody += msg;
//Add an attachment.
String sDisplayName = "Coopcheck Log";
int iPosition = (int)oMsg.Body.Length + 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
// now attached the file
Outlook.Attachment oAttach = oMsg.Attachments.Add(attachementFileName, iAttachType, iPosition, sDisplayName);
//Subject line
oMsg.Subject = subject;
// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
foreach (var i in toList)
{
Outlook.Recipient oRecip = (Outlook.Recipient) oRecips.Add(i);
oRecip.Resolve();
}
oMsg.Send();
}
示例13: GetCalendarEvents
public List<CalendarEvent> GetCalendarEvents(DateTime rangeFrom, DateTime rangeTo)
{
var app = new Outlook.Application();
Outlook.Folder calendarFolder = app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;
Outlook.Items outlookEvents = getAppointmentsInRange(calendarFolder, rangeFrom, rangeTo);
List<CalendarEvent> calendarEvents = new List<CalendarEvent>();
foreach (Outlook.AppointmentItem outlookEvent in outlookEvents)
{
var calendarEvent = new OutlookCalendarEvent()
{
DateFrom = outlookEvent.Start,
DateTo = outlookEvent.End,
Description = string.Format("{0}", outlookEvent.Body),
Location = outlookEvent.Location,
Title = outlookEvent.Subject,
ID = outlookEvent.GlobalAppointmentID,
SourceID = outlookEvent.ItemProperties["SourceID"] != null ? outlookEvent.ItemProperties["SourceID"].ToString() : outlookEvent.GlobalAppointmentID
};
calendarEvents.Add(calendarEvent);
}
return calendarEvents;
}
示例14: Print
public override string Print(WorkbookItem wi)
{
using (new WsActivationContext())
{
string destination = Utilities.GetTemporaryFileWithPdfExtension();
Outlook._Application app = new Outlook.Application();
Outlook._MailItem mailItem = app.Session.OpenSharedItem(wi.FileName) as Outlook._MailItem;
try
{
if (mailItem == null)
{
return null;
}
Publisher.PublishWithOutlook(destination, mailItem);
}
finally
{
if (mailItem != null)
{
mailItem.Close(Outlook.OlInspectorClose.olDiscard);
System.Runtime.InteropServices.Marshal.ReleaseComObject(mailItem);
}
}
return destination;
}
}
示例15: ThisAddIn_Startup
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
// Create an object of type Outlook.Application
Outlook.Application objOutlook = new Outlook.Application();
//Create an object of type olMailItem
Outlook.MailItem oIMailItem = objOutlook.CreateItem(Outlook.OlItemType.olMailItem);
//Set properties of the message file e.g. subject, body and to address
//Set subject
oIMailItem.Subject = "This MSG file is created using Office Automation.";
//Set to (recipient) address
oIMailItem.To = "[email protected]";
//Set body of the email message
oIMailItem.HTMLBody = "<html><p>This MSG file is created using VBA code.</p>";
//Add attachments to the message
oIMailItem.Attachments.Add("image.bmp");
oIMailItem.Attachments.Add("pic.jpeg");
//Save as Outlook MSG file
oIMailItem.SaveAs("testvba.msg");
//Open the MSG file
oIMailItem.Display();
}