email parsing automation

Email Parser

Extract data from emails and automate your workflow

The forum is now read only. Please, go to the the main Email Parser website if you need help.
Post here if you experience problems or get unexpected errors.
How do we get access to the shortname (without full path) of an attachment when using variable in SQL update query?

I can get it to update my table - but it puts the full pathname in and I just want the shortname (just the filename) when using <%Attachment%>

(I have attachment saving to specific path)
This requires some scripting to extract the file name from the full path. I have attached an example file to this post.

The Email&Parser scripting SDK is here: http://www.automatedemailparser.com/d/e ... ing-sdk-52

[syntax=csharp]
using System;
using System.Text;
using System.IO;
using System.Net.Mail;
using System.Collections.Specialized;
using EmailAndParser.ScriptingInterface;

public class MyAction : ScriptBasedAction
{
public override bool Run(MailMessage email, NameValueCollection fields)
{
// Check that we have some attachments saved
if (fields.GetValues("Attachment") == null)
{
Print("This email has no attachments");
return (false);
}

// For each value stored in the attachment field
// create a new value with the file name only
foreach (string attachment_path in fields.GetValues("Attachment"))
{
string filename = Path.GetFileName(attachment_path);
fields.Add("attachment_filenames", filename);
Print("Attachment filename:"+ filename);
}

// this script finishes successfully
return (true);
}
}

[/syntax]
Attachments