本文整理汇总了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类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:28,代码来源:OutboxMonitor.cs
示例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);
}
开发者ID:mind0n,项目名称:hive,代码行数:9,代码来源:OutlookPortal.cs
示例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();
}
开发者ID:GeneArnold,项目名称:SalesLogix-Outlook-Link,代码行数:10,代码来源:ThisAddIn.Designer.cs
示例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;
}
开发者ID:rburgstaler,项目名称:Outlook-To-Google-Calendar-Sync,代码行数:53,代码来源:CalendarManagerOutlook.cs
示例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();
}
开发者ID:ldoguin,项目名称:NuxeoOutlookAddin,代码行数:14,代码来源:ThisAddIn.Designer.cs
示例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();
}
开发者ID:pavel-visionmap,项目名称:VM-Odesk-Code,代码行数:43,代码来源:Calendar.cs
示例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);
}
开发者ID:twreid,项目名称:PracticumEmailer,代码行数:20,代码来源:parser.cs
示例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);
}
开发者ID:manivts,项目名称:impexcubeapp,代码行数:25,代码来源:OutlookMail.cs
示例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;
}
开发者ID:xneo123,项目名称:OutlookMachine,代码行数:38,代码来源:OutlookContentInput.cs
示例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)
{
}
}
开发者ID:pisceanfoot,项目名称:outlooklink,代码行数:23,代码来源:OutlookTool.cs
示例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;
}
}
开发者ID:kenuyx,项目名称:SR-Wellness-Report-Tool,代码行数:28,代码来源:MailMessager.cs
示例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);
//.........这里部分代码省略.........
开发者ID:atul898,项目名称:standup,代码行数:101,代码来源:YaharaEmployeeStatusService.cs
示例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();
}
开发者ID:AndreasDerFuchs,项目名称:KepiCrawler,代码行数:64,代码来源:KepiCrawler.cs
示例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());
}
开发者ID:azarkevich,项目名称:TortoiseRally,代码行数:101,代码来源:MyWork.cs
示例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)
//.........这里部分代码省略.........
开发者ID:netthanhhung,项目名称:Neos,代码行数:101,代码来源:Common.cs
示例16: GetApplicationObject
private static Microsoft.Office.Interop.Outlook.Application GetApplicationObject()
{
Microsoft.Office.Interop.Outlook.Application application = null;
// Check whether there is an Outlook process running.
if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
{
// If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
application = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
}
else
{
// If not, create a new instance of Outlook and log on to the default profile.
application = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
nameSpace.Logon("yahara\test", "test1234", System.Reflection.Missing.Value, System.Reflection.Missing.Value);
//nameSpace = null;
}
// Return the Outlook Application object.
return application;
}
开发者ID:atul898,项目名称:standup,代码行数:24,代码来源:YaharaEmployeeStatusService.cs
示例17: read
public void read()
{
Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace ns = outlook.GetNamespace("Mapi");
object _missing = Type.Missing;
ns.Logon(_missing, _missing, false, true);
Microsoft.Office.Interop.Outlook.MAPIFolder inbox = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
string foldername = inbox.Name;
int iMailCount = inbox.Items.Count;
TraceService("Inside read method");
for(int iCount =1 ;iCount <= iMailCount;iCount++)
{
Object mail1 = inbox.Items[iCount];
if (((mail1 as Microsoft.Office.Interop.Outlook.MailItem) != null) && ((mail1 as Microsoft.Office.Interop.Outlook.MailItem).UnRead == true))
{
TraceService("Inside unread mail");
Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)inbox.Items[iCount];
SqlConnection con;
string connection = @"server=CSM-DEV\SQL2008;database=TerexBest;uid=sa;[email protected]";
TraceService("Connection with database done1");
con = new SqlConnection(connection);
SqlCommand cmd;
cmd = new SqlCommand();
con.Open();
cmd.Connection = con;
TraceService("Connection assigned to sql command");
string subject = mail.Subject.ToString();
TraceService("mail subject written"+subject);
string body = mail.Body.ToString();
cmd.Parameters.Add("@subject", SqlDbType.NVarChar).Value = subject;
TraceService(subject); //writing subject
cmd.Parameters.Add("@body", SqlDbType.NVarChar).Value = body;
TraceService(body); //writing subject
cmd.Parameters.Add("@recievedtime", SqlDbType.DateTime).Value = mail.ReceivedTime;
TraceService(mail.ReceivedTime.ToString()); //writing subject
cmd.Parameters.Add("@mailfrom", SqlDbType.NVarChar).Value = mail.SenderEmailAddress;
TraceService(mail.SenderEmailAddress); //writing subject
TraceService("Before Inventory saved");
cmd.CommandText = "insert into storemail(subject,body,createddatetime,mailfrom,isActive) values(@subject,@body,@recievedtime,@mailfrom,1)";
TraceService("Inventory saved");
try
{
cmd.ExecuteNonQuery();
mail.Delete();
iMailCount = iMailCount - 1;
}
catch (SqlException ex)
{
ex.ToString();
}
con.Close();
cmd.Dispose();
con.Dispose();
}
}
GC.Collect();
inbox = null;
ns = null;
outlook = null;
}
开发者ID:progressiveinfotech,项目名称:PRO_FY13_40_Helpdesk-Support-and-Customization_EIHAutoMail,代码行数:73,代码来源:Service1.cs
示例18: OnButtonInvoiceEmailSelectionClicked
protected void OnButtonInvoiceEmailSelectionClicked(object sender, EventArgs e)
{
GridItemCollection col = gridInvoice.SelectedItems;
IList<Invoices> invoiceList = new List<Invoices>();
string email = string.Empty;
foreach (GridDataItem item in col)
{
TableCell cell = item["InvoiceIdPK"];
if (!string.IsNullOrEmpty(cell.Text))
{
string[] key = cell.Text.Split('-');
int idFactNumber = int.Parse(key[0]);
string type = key[1];
int idYear = int.Parse(key[2]);
Invoices invoice = new InvoicesRepository().GetInvoiceByID(idFactNumber, type, idYear);
invoiceList.Add(invoice);
CompanyAddress address = new CompanyAddressRepository().FindOne(
new CompanyAddress(invoice.RefCustomerNumber.Value));
if (!string.IsNullOrEmpty(address.Email))
{
if (email == string.Empty)
{
email = address.Email.Trim();
}
else if (email != address.Email.Trim())
{
string message = ResourceManager.GetString("messageInvoicesNotHaveSameEmail");
string script1 = "<script type=\"text/javascript\">";
script1 += " alert(\"" + message + "\")";
script1 += " </script>";
if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
return;
}
}
else
{
string message = ResourceManager.GetString("messageInvoiceNotHaveAnyEmail");
string script1 = "<script type=\"text/javascript\">";
script1 += " alert(\"" + message + "\")";
script1 += " </script>";
if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
return;
}
}
}
Microsoft.Office.Interop.Outlook.Application outlookApp =
new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem)
outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
mailItem.To = email;
mailItem.Subject = "Send invoice";
foreach (Invoices item in invoiceList)
{
string fileName = Common.ExportInvoices(
item, WebConfig.AddressFillInInvoice, WebConfig.AbsoluteExportDirectory);
mailItem.Attachments.Add(fileName,
Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
}
mailItem.Display(true);
}
开发者ID:netthanhhung,项目名称:Neos,代码行数:68,代码来源:InvoicesPage.aspx.cs
示例19: Dispose
public void Dispose()
{
_disposing = true;
ClosePendingSubmitWaitHandles();
if (_items != null)
{
_items.ItemAdd -= Items_ItemAdd;
_items = null;
}
if (_outbox != null)
{
((IDisposable)_outbox).Dispose();
_outbox = null;
|
请发表评论