Skip to content

Commit

Permalink
Added Mailitem Lists to BeginListLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
openbots-ff committed Mar 20, 2020
1 parent cbe2249 commit 290aa85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 7 additions & 2 deletions taskt/Core/Automation/Commands/BeginListLoopCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Forms;
using taskt.UI.Forms;
using taskt.UI.CustomControls;
using Microsoft.Office.Interop.Outlook;

namespace taskt.Core.Automation.Commands
{
Expand Down Expand Up @@ -59,7 +60,7 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo
//if still null then throw exception
if (complexVariable == null)
{
throw new Exception("Complex Variable '" + v_LoopParameter + "' or '" + v_LoopParameter.ApplyVariableFormatting() + "' not found. Ensure the variable exists before attempting to modify it.");
throw new System.Exception("Complex Variable '" + v_LoopParameter + "' or '" + v_LoopParameter.ApplyVariableFormatting() + "' not found. Ensure the variable exists before attempting to modify it.");
}

dynamic listToLoop;
Expand All @@ -75,6 +76,10 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo
{
listToLoop = ((DataTable)complexVariable.VariableValue).Rows;
}
else if (complexVariable.VariableValue is List<MailItem>)
{
listToLoop = (List<MailItem>)complexVariable.VariableValue;
}
else if ((complexVariable.VariableValue.ToString().StartsWith("[")) && (complexVariable.VariableValue.ToString().EndsWith("]")) && (complexVariable.VariableValue.ToString().Contains(",")))
{
//automatically handle if user has given a json array
Expand All @@ -92,7 +97,7 @@ public override void RunCommand(object sender, Core.Script.ScriptAction parentCo
}
else
{
throw new Exception("Complex Variable List Type<T> Not Supported");
throw new System.Exception("Complex Variable List Type<T> Not Supported");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public override List<Control> Render(frmCommandEditor editor)

public override string GetDisplayValue()
{
return base.GetDisplayValue();
return base.GetDisplayValue() + $" [From: {v_InputData}, Get: {v_Key}, Store In: {v_OutputVariable}]";
}
}
}
14 changes: 9 additions & 5 deletions taskt/Core/Automation/Commands/OutlookGetEmailsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,17 @@ private void ProcessEmail(MailItem mail, string msgDirectory, string attDirector
{
mail.UnRead = false;
}
if (v_SaveMessagesAndAttachments == "Yes" && System.IO.Directory.Exists(msgDirectory) && System.IO.Directory.Exists(attDirectory))
if (v_SaveMessagesAndAttachments == "Yes")
{
mail.SaveAs(System.IO.Path.Combine(msgDirectory, mail.Subject + ".msg"));
foreach (Attachment attachment in mail.Attachments)
if (System.IO.Directory.Exists(msgDirectory))
mail.SaveAs(System.IO.Path.Combine(msgDirectory, mail.Subject + ".msg"));
if (System.IO.Directory.Exists(attDirectory))
{
attachment.SaveAsFile(System.IO.Path.Combine(attDirectory, attachment.FileName));
}
foreach (Attachment attachment in mail.Attachments)
{
attachment.SaveAsFile(System.IO.Path.Combine(attDirectory, attachment.FileName));
}
}
}
}

Expand Down

0 comments on commit 290aa85

Please sign in to comment.