Beruflich Dokumente
Kultur Dokumente
// Rules by Sender
switch (sender)
{
case "zachary@customerA.com":
fileName = ExtractString(m.Subject, "(", ")");
case "hunter@customerB.com":
switch (filePrefix)
{
case "DAILY":
fileName = "CustomerB_Inventory";
break;
case "PULL":
fileName = "CustomerB_Pulls";
break;
case "RECEIPT":
fileName = "CustomerB_Receipts";
break;
}
attachment.Save(@"C:\Demo\" + fileName +
Path.GetExtension(attachment.Filename));
}
break;
}
/// <summary>
/// Helper method to pull out a string between a start and stop string.
/// Example:
/// string story = "The boy and the cat ran to the store.";
/// ExtractString(story, "cat", "to"); //returns "ran"
/// </summary>
/// <param name="stringToParse">String to search</param>
/// <param name="startTag">Starting String Pattern</param>
/// <param name="endTag">Ending String Pattern</param>
/// <returns>String found between the Starting and Ending Pattern.</returns>
static string ExtractString(string stringToParse, string startTag, string endTag)
{
int startIndex = stringToParse.IndexOf(startTag) + startTag.Length;
int endIndex = stringToParse.IndexOf(endTag, startIndex);
return stringToParse.Substring(startIndex, endIndex - startIndex);
}