Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to check that multiple Outlook dialogues aren't being created for same Email/Filename?
    primarykey
    data
    text
    <p>I am using C#.NET in VS2010. In my below code I check each record in a datagrid for having been selected for Reporting. If selected, I then check each of the 3 available contact fields to see if that entity needs to be contacted by having the generated report emailed to them. </p> <p>Filenames are saved as “IN_MUL_*BusinessID_Date_Time_ContactPoint*”, ex. “IN_MUL_25_05202013_09.11.14_BUS”. If I select 2 test results to report from the same Sample#, meaning they have the same ContactResults structure on their Account, 2 email dialogues open to the same person, with the same report attached. In this situation, the code is processing correctly, but logically I only need the one dialogue as it's the same report to the same individual.</p> <p>Does anyone know of a fairly easy way I could check if a dialogue to a person and with a particular attachment has already been created, and if so, ignore that processing?</p> <p>My code is below:</p> <pre><code>private void emailReports() { foreach (DataGridViewRow recRow in dgvTests.Rows) { if (((recRow.Cells["Select"].Value != null) &amp;&amp; Boolean.Parse(recRow.Cells["Select"].Value.ToString()))) { // If Business should be contacted with Sample Test Results if ((recRow.Cells["BusinessContactResults"].Value != null) &amp;&amp; (Boolean.Parse(recRow.Cells["BusinessContactResults"].Value.ToString()) == true) &amp;&amp; (recRow.Cells["BusinessEmail"].Value != null)) { Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mail = null; mail = (Microsoft.Office.Interop.Outlook.MailItem)objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mail.To = recRow.Cells["BusinessEmail"].Value.ToString(); mail.Subject = "Inspection Notification"; mail.Body = ""; mail.Attachments.Add((object)string.Format("{0}IN_{1}_{2}_{3}_BUS.pdf", reptLoc, strLSN, recRow.Cells["BusinessID"].Value, dtString), Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Attachment"); mail.Display(); } if ((recRow.Cells["SupplierContactResults"].Value != null) &amp;&amp; (Boolean.Parse(recRow.Cells["SupplierContactResults"].Value.ToString()) == true) &amp;&amp; (recRow.Cells["SupplierEmail"].Value != null)) { Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mail = null; mail = (Microsoft.Office.Interop.Outlook.MailItem)objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mail.To = recRow.Cells["SupplierEmail"].Value.ToString(); mail.Subject = "Inspection Notification"; mail.Body = ""; mail.Attachments.Add((object)string.Format("{0}IN_{1}_{2}_{3}_SUP.pdf", reptLoc, strLSN, recRow.Cells["BusinessID"].Value, dtString), Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Attachment"); mail.Display(); } if ((recRow.Cells["CorporateContactResults"].Value != null) &amp;&amp; (Boolean.Parse(recRow.Cells["CorporateContactResults"].Value.ToString()) == true) &amp;&amp; (recRow.Cells["CorporateEmail"].Value != null)) { Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mail = null; mail = (Microsoft.Office.Interop.Outlook.MailItem)objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); mail.To = recRow.Cells["CorporateEmail"].Value.ToString(); mail.Subject = "Inspection Notification"; mail.Body = ""; mail.Attachments.Add((object)string.Format("{0}IN_{1}_{2}_{3}_CRP.pdf", reptLoc, strLSN, recRow.Cells["BusinessID"].Value, dtString), Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, (object)"Attachment"); mail.Display(); } } } } </code></pre> <p>Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload