Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- listOfStrings Count = 13 [0]: "t" [1]: "x" [2]: "m" [3]: "l" [4]: "n" [5]: "s" [6]:
- ":" [7]: "s" [8]: "s" [9]: "=" [10]: """ [11]: "u" [12]: "r".
- 3/21/2018 9:57:53 PM 54 West Entrance West Vending - West Entrance 123456789
- FirstName LastName 255061 V4 Protective Eyewear 11 6242-A5 1 $1.71 $1.71 1
- $1.71
- namespace OutlookAddIn1
- {
- public partial class Ribbon1
- {
- //change paths when working
- string path = @"H:Customer Service";
- string archivePath = @"H:Customer ServiceHelpers";
- List<String> listOfStrings = new List<string>();
- private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
- {
- }
- private void button1_Click(object sender, RibbonControlEventArgs e)
- {
- Outlook.Inspector currInspector = null;
- Outlook.MailItem mail = null;
- Outlook.Attachments attachments = null;
- try
- {
- currInspector = Globals.ThisAddIn.Application.ActiveWindow();
- mail = (Outlook.MailItem)currInspector.CurrentItem;
- attachments = mail.Attachments;
- for (int i = 1; i <= attachments.Count; i++)
- {
- Outlook.Attachment vendFile = attachments[i];
- //save original in archive folder
- string archiveFilePath = Path.Combine(archivePath, vendFile.FileName);
- string processFilePath = Path.Combine(path, vendFile.FileName);
- vendFile.SaveAsFile(archiveFilePath);
- //begin document modification and save to path
- StreamReader streamReader = new StreamReader(new FileStream(archiveFilePath, FileMode.Open, FileAccess.Read));
- StreamWriter streamWriter = new StreamWriter(new FileStream(processFilePath, FileMode.Create, FileAccess.Write));
- using (streamReader)
- using (streamWriter)
- {
- while (streamReader.Peek() != -1)
- {
- streamReader.ReadLine();
- streamReader.ReadLine();
- streamReader.ReadLine();
- streamReader.ReadLine();
- streamReader.ReadLine();
- foreach(var row in streamReader.ReadLine())
- {
- listOfStrings.Add(row.ToString());
- }
- }
- }
- //dispose of COM object
- Marshal.ReleaseComObject(vendFile);
- }
- }
- catch
- {
- MessageBox.Show("Unable to retrieve attachment");
- }
- finally
- {
- if (attachments != null) Marshal.ReleaseComObject(attachments);
- if (mail != null) Marshal.ReleaseComObject(mail);
- if (currInspector != null) Marshal.ReleaseComObject(currInspector);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment