Guest User

Untitled

a guest
Jun 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. listOfStrings Count = 13 [0]: "t" [1]: "x" [2]: "m" [3]: "l" [4]: "n" [5]: "s" [6]:
  2. ":" [7]: "s" [8]: "s" [9]: "=" [10]: """ [11]: "u" [12]: "r".
  3.  
  4. 3/21/2018 9:57:53 PM 54 West Entrance West Vending - West Entrance 123456789
  5. FirstName LastName 255061 V4 Protective Eyewear 11 6242-A5 1 $1.71 $1.71 1
  6. $1.71
  7.  
  8. namespace OutlookAddIn1
  9. {
  10. public partial class Ribbon1
  11. {
  12. //change paths when working
  13. string path = @"H:Customer Service";
  14. string archivePath = @"H:Customer ServiceHelpers";
  15. List<String> listOfStrings = new List<string>();
  16.  
  17. private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
  18. {
  19.  
  20. }
  21.  
  22. private void button1_Click(object sender, RibbonControlEventArgs e)
  23. {
  24. Outlook.Inspector currInspector = null;
  25. Outlook.MailItem mail = null;
  26. Outlook.Attachments attachments = null;
  27.  
  28. try
  29. {
  30.  
  31. currInspector = Globals.ThisAddIn.Application.ActiveWindow();
  32. mail = (Outlook.MailItem)currInspector.CurrentItem;
  33. attachments = mail.Attachments;
  34.  
  35. for (int i = 1; i <= attachments.Count; i++)
  36. {
  37. Outlook.Attachment vendFile = attachments[i];
  38. //save original in archive folder
  39. string archiveFilePath = Path.Combine(archivePath, vendFile.FileName);
  40. string processFilePath = Path.Combine(path, vendFile.FileName);
  41. vendFile.SaveAsFile(archiveFilePath);
  42.  
  43. //begin document modification and save to path
  44. StreamReader streamReader = new StreamReader(new FileStream(archiveFilePath, FileMode.Open, FileAccess.Read));
  45. StreamWriter streamWriter = new StreamWriter(new FileStream(processFilePath, FileMode.Create, FileAccess.Write));
  46. using (streamReader)
  47. using (streamWriter)
  48. {
  49. while (streamReader.Peek() != -1)
  50. {
  51. streamReader.ReadLine();
  52. streamReader.ReadLine();
  53. streamReader.ReadLine();
  54. streamReader.ReadLine();
  55. streamReader.ReadLine();
  56. foreach(var row in streamReader.ReadLine())
  57. {
  58. listOfStrings.Add(row.ToString());
  59. }
  60. }
  61. }
  62.  
  63. //dispose of COM object
  64. Marshal.ReleaseComObject(vendFile);
  65. }
  66.  
  67. }
  68. catch
  69. {
  70. MessageBox.Show("Unable to retrieve attachment");
  71. }
  72. finally
  73. {
  74. if (attachments != null) Marshal.ReleaseComObject(attachments);
  75. if (mail != null) Marshal.ReleaseComObject(mail);
  76. if (currInspector != null) Marshal.ReleaseComObject(currInspector);
  77. }
  78.  
  79. }
  80. }
  81. }
Add Comment
Please, Sign In to add comment