diff --git a/Program.cs b/Program.cs index 0467e15..15f3765 100644 --- a/Program.cs +++ b/Program.cs @@ -90,7 +90,8 @@ namespace jdis_import list.Add(todo); //Download File FileAttachment fAttachment = attachment as FileAttachment; - File.WriteAllBytes(fAttachment.Name, fAttachment.Content); + string fileAttachmentPath = Path.Combine(_exeDir, fAttachment.FileName); + File.WriteAllBytes(fileAttachmentPath, fAttachment.Content); msg.IsRead = true; } } @@ -116,7 +117,7 @@ namespace jdis_import else { body = string.Format(body, sendMsg.FileName, sendMsg.WorkOrder, string.Format("Had Errors while importing: {0}", sendMsg.Validation)); - msgToSend.Attachments.AddFileAttachment(sendMsg.FileName); + msgToSend.Attachments.AddFileAttachment(Path.Combine(_exeDir, sendMsg.FileName) } @@ -125,8 +126,9 @@ namespace jdis_import msgToSend.CcRecipients.Add(new EmailAddress("mcarman@rpmindustries.com")); msgToSend.Body = body; msgToSend.SendAndSaveCopy(); - if (sendMsg.Success) File.Move(sendMsg.FileName, Path.Combine("Success", sendMsg.FileName)); - else File.Move(sendMsg.FileName, Path.Combine("Fail", sendMsg.FileName)); + string pathToFile = Path.Combine(_exeDir, sendMsg.FileName); + if (sendMsg.Success) File.Move(pathToFile, Path.Combine(_exeDir, "Success", sendMsg.FileName)); + else File.Move(sendMsg.FileName, Path.Combine(_exeDir, "Fail", sendMsg.FileName)); } } catch (MsalException ex)