Moving multiple PDFs to different folders
up vote
0
down vote
favorite
Need some help in code refactoring as there is lot of duplicated code in my MoveMultiplePagePdfToFolder
checks for multiple pdf attachments in message and if all of them contain single page then it moves the message to Processed
otherwise Rejected
.
public class Client
{
private List<MailMessage> _mailMessages;
/// <summary>
/// This method checks if a pdf file is editable.
/// </summary>
/// <param name="fileContents"></param>
/// <returns>true (if editable) or false (if not editable)</returns>
private bool IsEditablePdf(byte fileContents)
{
var pdfReader = new PdfReader(fileContents);
if (pdfReader.AcroForm == null)
return false;
return true;
}
/// <summary>
/// This method converts an editable pdf to uneditable pdf.
/// </summary>
/// <param name="fileContents"></param>
/// <returns></returns>
private byte GetUnEditablePdf(byte fileContents)
{
byte uneditableFileContents;
var reader = new PdfReader(fileContents);
if (reader.AcroForm != null)
uneditableFileContents = FlattenPdfFormToBytes(reader);
else uneditableFileContents = fileContents;
return uneditableFileContents;
}
private List<MailMessage> GetMailWithSinglePdf()
{
var mailMessagesWithSinglePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount == 1)
mailMessagesWithSinglePdf.Add(message);
}
}
return mailMessagesWithSinglePdf;
}
private List<MailMessage> GetMailWithMultiplePdf()
{
var mailMessagesWithMultiplePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount > 1)
mailMessagesWithMultiplePdf.Add(message);
}
}
return mailMessagesWithMultiplePdf;
}
private int PageCount(FileAttachment pdfAttachment)
{
using (var reader = new PdfReader(pdfAttachment.Content))
return reader.NumberOfPages;
}
private void SaveToEmaDirectory(string filePath, byte fileContent)
{
File.WriteAllBytes(filePath, fileContent);
}
private string GenerateFilePath(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return Path.Combine(
Statics.EmaFileWatcherWorkingDirectory,
GenerateFileName(singlePagePdf));
}
private string GenerateFileName(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return string.Join("_",
"fax",
DateTime.Now.Date.ToString("ddMMyy"),
singlePagePdf.Name,
DateTime.Now.Ticks + ".pdf");
}
private byte UnEditableVersionOf(byte pdfContent)
{
if (pdfContent == null) throw new ArgumentNullException(nameof(pdfContent));
return IsEditablePdf(pdfContent)
? GetUnEditablePdf(pdfContent)
: pdfContent;
}
/// <summary>
/// Moves this item to a the specified folder. Calling this method results in a call to EWS.
/// </summary>
/// <param name="destinationFolderName"></param>
/// <param name="messages"></param>
public void MoveMailToFolder(string destinationFolderName, List<MailMessage> messages)
{
if (string.IsNullOrWhiteSpace(destinationFolderName))
throw new MessageException("Invalid folder name");
if (messages != null && (messages.Any()))
{
var fId = GetFolderId(destinationFolderName);
var results = WorkingFolder.FindItems(new ItemView(100));
if (results?.Items?.Count > 0)
foreach (var item in results.Items)
{
if (item is EmailMessage)
{
item.Load();
var mailMessage = new MailMessage();
mailMessage.Id = item.Id.ToString();
if (messages.Contains(mailMessage))
item.Move(fId);
}
}
}
}
public void MoveSinglePagePdfToFolder()
{
var messagesWithSinglePdf = GetMailWithSinglePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithSinglePdf?.Count > 0)
{
foreach (var message in messagesWithSinglePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachment = message
.Attachments
.Cast<FileAttachment>()
.Single(attachment => attachment.Name.EndsWith(".pdf"));
if (PageCount(pdfAttachment) == 1)
{
SaveToEmaDirectory(GenerateFilePath(pdfAttachment), UnEditableVersionOf(pdfAttachment.Content));
processed.Add(message);
}
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
public void MoveMultiplePagePdfToFolder()
{
var messagesWithMultiplePdf = GetMailWithMultiplePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithMultiplePdf?.Count > 0)
{
foreach (var message in messagesWithMultiplePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachmentList = message
.Attachments
.Cast<FileAttachment>()
.Where(attachment => attachment.Name.EndsWith(".pdf"));
bool isMessageOk = true;
foreach (var pdfAttachment in pdfAttachmentList)
{
if (PageCount(pdfAttachment) != 1)
/*SaveToEmaDirectory(GenerateFilePath(pdfAttachment),
UnEditableVersionOf(pdfAttachment.Content))*/;
isMessageOk = false;
}
if(isMessageOk)
processed.Add(message);
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
}
The two methods MoveMultiplePagePdfToFolder
and MoveSinglePagePdfToFolder
are nearly same. MoveSinglePagePdfToFolder
contains all email messages with single pdf as attachments and if the number of pages in pdf is 1, then it sends to Processed folder else Rejected.
c# asp.net
New contributor
add a comment |
up vote
0
down vote
favorite
Need some help in code refactoring as there is lot of duplicated code in my MoveMultiplePagePdfToFolder
checks for multiple pdf attachments in message and if all of them contain single page then it moves the message to Processed
otherwise Rejected
.
public class Client
{
private List<MailMessage> _mailMessages;
/// <summary>
/// This method checks if a pdf file is editable.
/// </summary>
/// <param name="fileContents"></param>
/// <returns>true (if editable) or false (if not editable)</returns>
private bool IsEditablePdf(byte fileContents)
{
var pdfReader = new PdfReader(fileContents);
if (pdfReader.AcroForm == null)
return false;
return true;
}
/// <summary>
/// This method converts an editable pdf to uneditable pdf.
/// </summary>
/// <param name="fileContents"></param>
/// <returns></returns>
private byte GetUnEditablePdf(byte fileContents)
{
byte uneditableFileContents;
var reader = new PdfReader(fileContents);
if (reader.AcroForm != null)
uneditableFileContents = FlattenPdfFormToBytes(reader);
else uneditableFileContents = fileContents;
return uneditableFileContents;
}
private List<MailMessage> GetMailWithSinglePdf()
{
var mailMessagesWithSinglePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount == 1)
mailMessagesWithSinglePdf.Add(message);
}
}
return mailMessagesWithSinglePdf;
}
private List<MailMessage> GetMailWithMultiplePdf()
{
var mailMessagesWithMultiplePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount > 1)
mailMessagesWithMultiplePdf.Add(message);
}
}
return mailMessagesWithMultiplePdf;
}
private int PageCount(FileAttachment pdfAttachment)
{
using (var reader = new PdfReader(pdfAttachment.Content))
return reader.NumberOfPages;
}
private void SaveToEmaDirectory(string filePath, byte fileContent)
{
File.WriteAllBytes(filePath, fileContent);
}
private string GenerateFilePath(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return Path.Combine(
Statics.EmaFileWatcherWorkingDirectory,
GenerateFileName(singlePagePdf));
}
private string GenerateFileName(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return string.Join("_",
"fax",
DateTime.Now.Date.ToString("ddMMyy"),
singlePagePdf.Name,
DateTime.Now.Ticks + ".pdf");
}
private byte UnEditableVersionOf(byte pdfContent)
{
if (pdfContent == null) throw new ArgumentNullException(nameof(pdfContent));
return IsEditablePdf(pdfContent)
? GetUnEditablePdf(pdfContent)
: pdfContent;
}
/// <summary>
/// Moves this item to a the specified folder. Calling this method results in a call to EWS.
/// </summary>
/// <param name="destinationFolderName"></param>
/// <param name="messages"></param>
public void MoveMailToFolder(string destinationFolderName, List<MailMessage> messages)
{
if (string.IsNullOrWhiteSpace(destinationFolderName))
throw new MessageException("Invalid folder name");
if (messages != null && (messages.Any()))
{
var fId = GetFolderId(destinationFolderName);
var results = WorkingFolder.FindItems(new ItemView(100));
if (results?.Items?.Count > 0)
foreach (var item in results.Items)
{
if (item is EmailMessage)
{
item.Load();
var mailMessage = new MailMessage();
mailMessage.Id = item.Id.ToString();
if (messages.Contains(mailMessage))
item.Move(fId);
}
}
}
}
public void MoveSinglePagePdfToFolder()
{
var messagesWithSinglePdf = GetMailWithSinglePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithSinglePdf?.Count > 0)
{
foreach (var message in messagesWithSinglePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachment = message
.Attachments
.Cast<FileAttachment>()
.Single(attachment => attachment.Name.EndsWith(".pdf"));
if (PageCount(pdfAttachment) == 1)
{
SaveToEmaDirectory(GenerateFilePath(pdfAttachment), UnEditableVersionOf(pdfAttachment.Content));
processed.Add(message);
}
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
public void MoveMultiplePagePdfToFolder()
{
var messagesWithMultiplePdf = GetMailWithMultiplePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithMultiplePdf?.Count > 0)
{
foreach (var message in messagesWithMultiplePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachmentList = message
.Attachments
.Cast<FileAttachment>()
.Where(attachment => attachment.Name.EndsWith(".pdf"));
bool isMessageOk = true;
foreach (var pdfAttachment in pdfAttachmentList)
{
if (PageCount(pdfAttachment) != 1)
/*SaveToEmaDirectory(GenerateFilePath(pdfAttachment),
UnEditableVersionOf(pdfAttachment.Content))*/;
isMessageOk = false;
}
if(isMessageOk)
processed.Add(message);
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
}
The two methods MoveMultiplePagePdfToFolder
and MoveSinglePagePdfToFolder
are nearly same. MoveSinglePagePdfToFolder
contains all email messages with single pdf as attachments and if the number of pages in pdf is 1, then it sends to Processed folder else Rejected.
c# asp.net
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Need some help in code refactoring as there is lot of duplicated code in my MoveMultiplePagePdfToFolder
checks for multiple pdf attachments in message and if all of them contain single page then it moves the message to Processed
otherwise Rejected
.
public class Client
{
private List<MailMessage> _mailMessages;
/// <summary>
/// This method checks if a pdf file is editable.
/// </summary>
/// <param name="fileContents"></param>
/// <returns>true (if editable) or false (if not editable)</returns>
private bool IsEditablePdf(byte fileContents)
{
var pdfReader = new PdfReader(fileContents);
if (pdfReader.AcroForm == null)
return false;
return true;
}
/// <summary>
/// This method converts an editable pdf to uneditable pdf.
/// </summary>
/// <param name="fileContents"></param>
/// <returns></returns>
private byte GetUnEditablePdf(byte fileContents)
{
byte uneditableFileContents;
var reader = new PdfReader(fileContents);
if (reader.AcroForm != null)
uneditableFileContents = FlattenPdfFormToBytes(reader);
else uneditableFileContents = fileContents;
return uneditableFileContents;
}
private List<MailMessage> GetMailWithSinglePdf()
{
var mailMessagesWithSinglePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount == 1)
mailMessagesWithSinglePdf.Add(message);
}
}
return mailMessagesWithSinglePdf;
}
private List<MailMessage> GetMailWithMultiplePdf()
{
var mailMessagesWithMultiplePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount > 1)
mailMessagesWithMultiplePdf.Add(message);
}
}
return mailMessagesWithMultiplePdf;
}
private int PageCount(FileAttachment pdfAttachment)
{
using (var reader = new PdfReader(pdfAttachment.Content))
return reader.NumberOfPages;
}
private void SaveToEmaDirectory(string filePath, byte fileContent)
{
File.WriteAllBytes(filePath, fileContent);
}
private string GenerateFilePath(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return Path.Combine(
Statics.EmaFileWatcherWorkingDirectory,
GenerateFileName(singlePagePdf));
}
private string GenerateFileName(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return string.Join("_",
"fax",
DateTime.Now.Date.ToString("ddMMyy"),
singlePagePdf.Name,
DateTime.Now.Ticks + ".pdf");
}
private byte UnEditableVersionOf(byte pdfContent)
{
if (pdfContent == null) throw new ArgumentNullException(nameof(pdfContent));
return IsEditablePdf(pdfContent)
? GetUnEditablePdf(pdfContent)
: pdfContent;
}
/// <summary>
/// Moves this item to a the specified folder. Calling this method results in a call to EWS.
/// </summary>
/// <param name="destinationFolderName"></param>
/// <param name="messages"></param>
public void MoveMailToFolder(string destinationFolderName, List<MailMessage> messages)
{
if (string.IsNullOrWhiteSpace(destinationFolderName))
throw new MessageException("Invalid folder name");
if (messages != null && (messages.Any()))
{
var fId = GetFolderId(destinationFolderName);
var results = WorkingFolder.FindItems(new ItemView(100));
if (results?.Items?.Count > 0)
foreach (var item in results.Items)
{
if (item is EmailMessage)
{
item.Load();
var mailMessage = new MailMessage();
mailMessage.Id = item.Id.ToString();
if (messages.Contains(mailMessage))
item.Move(fId);
}
}
}
}
public void MoveSinglePagePdfToFolder()
{
var messagesWithSinglePdf = GetMailWithSinglePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithSinglePdf?.Count > 0)
{
foreach (var message in messagesWithSinglePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachment = message
.Attachments
.Cast<FileAttachment>()
.Single(attachment => attachment.Name.EndsWith(".pdf"));
if (PageCount(pdfAttachment) == 1)
{
SaveToEmaDirectory(GenerateFilePath(pdfAttachment), UnEditableVersionOf(pdfAttachment.Content));
processed.Add(message);
}
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
public void MoveMultiplePagePdfToFolder()
{
var messagesWithMultiplePdf = GetMailWithMultiplePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithMultiplePdf?.Count > 0)
{
foreach (var message in messagesWithMultiplePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachmentList = message
.Attachments
.Cast<FileAttachment>()
.Where(attachment => attachment.Name.EndsWith(".pdf"));
bool isMessageOk = true;
foreach (var pdfAttachment in pdfAttachmentList)
{
if (PageCount(pdfAttachment) != 1)
/*SaveToEmaDirectory(GenerateFilePath(pdfAttachment),
UnEditableVersionOf(pdfAttachment.Content))*/;
isMessageOk = false;
}
if(isMessageOk)
processed.Add(message);
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
}
The two methods MoveMultiplePagePdfToFolder
and MoveSinglePagePdfToFolder
are nearly same. MoveSinglePagePdfToFolder
contains all email messages with single pdf as attachments and if the number of pages in pdf is 1, then it sends to Processed folder else Rejected.
c# asp.net
New contributor
Need some help in code refactoring as there is lot of duplicated code in my MoveMultiplePagePdfToFolder
checks for multiple pdf attachments in message and if all of them contain single page then it moves the message to Processed
otherwise Rejected
.
public class Client
{
private List<MailMessage> _mailMessages;
/// <summary>
/// This method checks if a pdf file is editable.
/// </summary>
/// <param name="fileContents"></param>
/// <returns>true (if editable) or false (if not editable)</returns>
private bool IsEditablePdf(byte fileContents)
{
var pdfReader = new PdfReader(fileContents);
if (pdfReader.AcroForm == null)
return false;
return true;
}
/// <summary>
/// This method converts an editable pdf to uneditable pdf.
/// </summary>
/// <param name="fileContents"></param>
/// <returns></returns>
private byte GetUnEditablePdf(byte fileContents)
{
byte uneditableFileContents;
var reader = new PdfReader(fileContents);
if (reader.AcroForm != null)
uneditableFileContents = FlattenPdfFormToBytes(reader);
else uneditableFileContents = fileContents;
return uneditableFileContents;
}
private List<MailMessage> GetMailWithSinglePdf()
{
var mailMessagesWithSinglePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount == 1)
mailMessagesWithSinglePdf.Add(message);
}
}
return mailMessagesWithSinglePdf;
}
private List<MailMessage> GetMailWithMultiplePdf()
{
var mailMessagesWithMultiplePdf = new List<MailMessage>();
//load items from mailbox inbox folder
if (_mailMessages != null)
{
foreach (var message in _mailMessages)
{
var pdfCount = message.Attachments
.Where(z => z is FileAttachment).Count(p => p.Name.EndsWith(".pdf"));
// list of attachments contain one pdf
if (pdfCount > 1)
mailMessagesWithMultiplePdf.Add(message);
}
}
return mailMessagesWithMultiplePdf;
}
private int PageCount(FileAttachment pdfAttachment)
{
using (var reader = new PdfReader(pdfAttachment.Content))
return reader.NumberOfPages;
}
private void SaveToEmaDirectory(string filePath, byte fileContent)
{
File.WriteAllBytes(filePath, fileContent);
}
private string GenerateFilePath(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return Path.Combine(
Statics.EmaFileWatcherWorkingDirectory,
GenerateFileName(singlePagePdf));
}
private string GenerateFileName(FileAttachment singlePagePdf)
{
if (singlePagePdf == null) throw new ArgumentNullException(nameof(singlePagePdf));
return string.Join("_",
"fax",
DateTime.Now.Date.ToString("ddMMyy"),
singlePagePdf.Name,
DateTime.Now.Ticks + ".pdf");
}
private byte UnEditableVersionOf(byte pdfContent)
{
if (pdfContent == null) throw new ArgumentNullException(nameof(pdfContent));
return IsEditablePdf(pdfContent)
? GetUnEditablePdf(pdfContent)
: pdfContent;
}
/// <summary>
/// Moves this item to a the specified folder. Calling this method results in a call to EWS.
/// </summary>
/// <param name="destinationFolderName"></param>
/// <param name="messages"></param>
public void MoveMailToFolder(string destinationFolderName, List<MailMessage> messages)
{
if (string.IsNullOrWhiteSpace(destinationFolderName))
throw new MessageException("Invalid folder name");
if (messages != null && (messages.Any()))
{
var fId = GetFolderId(destinationFolderName);
var results = WorkingFolder.FindItems(new ItemView(100));
if (results?.Items?.Count > 0)
foreach (var item in results.Items)
{
if (item is EmailMessage)
{
item.Load();
var mailMessage = new MailMessage();
mailMessage.Id = item.Id.ToString();
if (messages.Contains(mailMessage))
item.Move(fId);
}
}
}
}
public void MoveSinglePagePdfToFolder()
{
var messagesWithSinglePdf = GetMailWithSinglePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithSinglePdf?.Count > 0)
{
foreach (var message in messagesWithSinglePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachment = message
.Attachments
.Cast<FileAttachment>()
.Single(attachment => attachment.Name.EndsWith(".pdf"));
if (PageCount(pdfAttachment) == 1)
{
SaveToEmaDirectory(GenerateFilePath(pdfAttachment), UnEditableVersionOf(pdfAttachment.Content));
processed.Add(message);
}
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
public void MoveMultiplePagePdfToFolder()
{
var messagesWithMultiplePdf = GetMailWithMultiplePdf();
var processed = new List<MailMessage>();
var rejected = new List<MailMessage>();
if (messagesWithMultiplePdf?.Count > 0)
{
foreach (var message in messagesWithMultiplePdf)
{
_service.GetAttachments(
message.Attachments.ToArray(),
BodyType.HTML,
null);
var pdfAttachmentList = message
.Attachments
.Cast<FileAttachment>()
.Where(attachment => attachment.Name.EndsWith(".pdf"));
bool isMessageOk = true;
foreach (var pdfAttachment in pdfAttachmentList)
{
if (PageCount(pdfAttachment) != 1)
/*SaveToEmaDirectory(GenerateFilePath(pdfAttachment),
UnEditableVersionOf(pdfAttachment.Content))*/;
isMessageOk = false;
}
if(isMessageOk)
processed.Add(message);
else rejected.Add(message);
}
MoveMailToFolder(Statics.Rejected, rejected);
MoveMailToFolder(Statics.Processed, processed);
}
}
}
The two methods MoveMultiplePagePdfToFolder
and MoveSinglePagePdfToFolder
are nearly same. MoveSinglePagePdfToFolder
contains all email messages with single pdf as attachments and if the number of pages in pdf is 1, then it sends to Processed folder else Rejected.
c# asp.net
c# asp.net
New contributor
New contributor
edited 17 mins ago
t3chb0t
33.6k744108
33.6k744108
New contributor
asked 2 hours ago
Gauravsa
1014
1014
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Gauravsa is a new contributor. Be nice, and check out our Code of Conduct.
Gauravsa is a new contributor. Be nice, and check out our Code of Conduct.
Gauravsa is a new contributor. Be nice, and check out our Code of Conduct.
Gauravsa is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f208209%2fmoving-multiple-pdfs-to-different-folders%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown