这就是我的......
我有一个跟踪条形码类型标签的程序。 我可以在数据库中选择一个项目并为其打印标签。 我正在添加将电子邮件发送到Exchange服务器(2007 SP1)上特定收件箱的功能,并在主题行中显示项目ID,然后使用该ID打印标签。 到目前为止,我可以从Exchange读取并提取ID号,然后将其发送到报告并打印报告。 我被困的地方是监控收件箱。 如何让readEmail()方法自动触发? 没有事件可以实现这一点。 我必须让它自己检查收件箱。 我们的想法是,如果我们需要打印标签,我们只需发送一封电子邮件到此收件箱,标签就会自动打印。 只有一个人可以打印这些,如果他不在这里并且有人需要标签,这可以让他发送电子邮件并打印标签。
private void readEmail() { ExchangeService _mailService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); _mailService.UseDefaultCredentials = true; _mailService.Url = new Uri("https://webmail.mydomain.com/ews/exchange.asmx"); try { ItemView allItems = new ItemView(100); SearchFilter searchFilterInbox = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false); Folder _inbox = Folder.Bind(_mailService, WellKnownFolderName.Inbox); if (_inbox.UnreadCount > 0) { FindItemsResults<Item> findResults = _inbox.FindItems(searchFilterInbox, allItems); List<Item> resultItems = new List<Item>(); foreach (Item item in findResults.Items) { resultItems.Add(item); _mailService.LoadPropertiesForItems(resultItems, PropertySet.FirstClassProperties); cboPropertyTag.Text = item.Subject; GetReportVariables(); reportType = "autoPrint"; reportViewer rv = new reportViewer(); rv.Show(); item.Move(WellKnownFolderName.DeletedItems); } } } catch (ServiceVersionException) { } }提前致谢!
保罗
Here's what I have...
I have a program that keeps track of barcode type labels. I can select an item in the database and print a label for it. I am adding the ability to send an email to a specific inbox on our Exchange server (2007 SP1) with the item ID in the subject line then print the label with that ID. So far I can read from Exchange and extract the ID number then send that to the report and have the report print it. Where I'm stuck is monitoring the inbox. How do I get the readEmail() method to fire automatically? There is no event to make this happen. I have to make it check the inbox by itself. The idea is so if we need a label printed, we can just send an email to this inbox and the label will print automatically. Only one person can print these and if he isn't here and someone needs a label, this lets him send an email and get the label printed.
private void readEmail() { ExchangeService _mailService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); _mailService.UseDefaultCredentials = true; _mailService.Url = new Uri("https://webmail.mydomain.com/ews/exchange.asmx"); try { ItemView allItems = new ItemView(100); SearchFilter searchFilterInbox = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false); Folder _inbox = Folder.Bind(_mailService, WellKnownFolderName.Inbox); if (_inbox.UnreadCount > 0) { FindItemsResults<Item> findResults = _inbox.FindItems(searchFilterInbox, allItems); List<Item> resultItems = new List<Item>(); foreach (Item item in findResults.Items) { resultItems.Add(item); _mailService.LoadPropertiesForItems(resultItems, PropertySet.FirstClassProperties); cboPropertyTag.Text = item.Subject; GetReportVariables(); reportType = "autoPrint"; reportViewer rv = new reportViewer(); rv.Show(); item.Move(WellKnownFolderName.DeletedItems); } } } catch (ServiceVersionException) { } }Thanks in advance!
Paul
最满意答案
想到的第一个想法是System.Timers.Timer ,它定期执行readEmail() 。
另一种选择是简单地为每隔x分钟运行一次的exe使用一个Scheduled Task并执行你的方法。
First idea that comes to mind is a System.Timers.Timer which regularly executes readEmail().
An other option would be a simply to use a Scheduled Task for an exe which runs every x minutes and executes your method.
以编程方式监视Exchange收件箱和打印标签(Programmatically monitor Exchange Inbox and print label)这就是我的......
我有一个跟踪条形码类型标签的程序。 我可以在数据库中选择一个项目并为其打印标签。 我正在添加将电子邮件发送到Exchange服务器(2007 SP1)上特定收件箱的功能,并在主题行中显示项目ID,然后使用该ID打印标签。 到目前为止,我可以从Exchange读取并提取ID号,然后将其发送到报告并打印报告。 我被困的地方是监控收件箱。 如何让readEmail()方法自动触发? 没有事件可以实现这一点。 我必须让它自己检查收件箱。 我们的想法是,如果我们需要打印标签,我们只需发送一封电子邮件到此收件箱,标签就会自动打印。 只有一个人可以打印这些,如果他不在这里并且有人需要标签,这可以让他发送电子邮件并打印标签。
private void readEmail() { ExchangeService _mailService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); _mailService.UseDefaultCredentials = true; _mailService.Url = new Uri("https://webmail.mydomain.com/ews/exchange.asmx"); try { ItemView allItems = new ItemView(100); SearchFilter searchFilterInbox = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false); Folder _inbox = Folder.Bind(_mailService, WellKnownFolderName.Inbox); if (_inbox.UnreadCount > 0) { FindItemsResults<Item> findResults = _inbox.FindItems(searchFilterInbox, allItems); List<Item> resultItems = new List<Item>(); foreach (Item item in findResults.Items) { resultItems.Add(item); _mailService.LoadPropertiesForItems(resultItems, PropertySet.FirstClassProperties); cboPropertyTag.Text = item.Subject; GetReportVariables(); reportType = "autoPrint"; reportViewer rv = new reportViewer(); rv.Show(); item.Move(WellKnownFolderName.DeletedItems); } } } catch (ServiceVersionException) { } }提前致谢!
保罗
Here's what I have...
I have a program that keeps track of barcode type labels. I can select an item in the database and print a label for it. I am adding the ability to send an email to a specific inbox on our Exchange server (2007 SP1) with the item ID in the subject line then print the label with that ID. So far I can read from Exchange and extract the ID number then send that to the report and have the report print it. Where I'm stuck is monitoring the inbox. How do I get the readEmail() method to fire automatically? There is no event to make this happen. I have to make it check the inbox by itself. The idea is so if we need a label printed, we can just send an email to this inbox and the label will print automatically. Only one person can print these and if he isn't here and someone needs a label, this lets him send an email and get the label printed.
private void readEmail() { ExchangeService _mailService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); _mailService.UseDefaultCredentials = true; _mailService.Url = new Uri("https://webmail.mydomain.com/ews/exchange.asmx"); try { ItemView allItems = new ItemView(100); SearchFilter searchFilterInbox = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false); Folder _inbox = Folder.Bind(_mailService, WellKnownFolderName.Inbox); if (_inbox.UnreadCount > 0) { FindItemsResults<Item> findResults = _inbox.FindItems(searchFilterInbox, allItems); List<Item> resultItems = new List<Item>(); foreach (Item item in findResults.Items) { resultItems.Add(item); _mailService.LoadPropertiesForItems(resultItems, PropertySet.FirstClassProperties); cboPropertyTag.Text = item.Subject; GetReportVariables(); reportType = "autoPrint"; reportViewer rv = new reportViewer(); rv.Show(); item.Move(WellKnownFolderName.DeletedItems); } } } catch (ServiceVersionException) { } }Thanks in advance!
Paul
最满意答案
想到的第一个想法是System.Timers.Timer ,它定期执行readEmail() 。
另一种选择是简单地为每隔x分钟运行一次的exe使用一个Scheduled Task并执行你的方法。
First idea that comes to mind is a System.Timers.Timer which regularly executes readEmail().
An other option would be a simply to use a Scheduled Task for an exe which runs every x minutes and executes your method.
发布评论