troubleshooting Question

How might this method be converted to VB.Net

Avatar of Ruffone
Ruffone asked on
ASP.NETVisual Basic.NET
5 Comments1 Solution372 ViewsLast Modified:
I ran it through an online converter and wound up with a not so perfect convertion

    private void BuildEmail(string template, Dictionary<string, string> parameters, out string subject, out string body, out string[] attachmentFiles, out string[] linkedResourceFiles)
    {
        ArrayList pathList;

        // Get linked resources
        Regex regex = new Regex("\"cid:([^\"]+)\"", RegexOptions.Multiline | RegexOptions.IgnoreCase);
        Match match = null;

        pathList = ((match = regex.Match(template)) != null) ? new ArrayList() : null;
        while (match.Groups.Count == 2)
        {
            pathList.Add(templateFolder + match.Groups[1].Value);
            match = match.NextMatch();
        }

        linkedResourceFiles = (string[])pathList.ToArray(typeof(string));

        // Get attachments
        regex = new Regex("<!--##ATTACHMENT:([^#]+)##-->");

        pathList = ((match = regex.Match(template)) != null) ? new ArrayList() : null;
        while (match.Groups.Count == 2)
        {
            pathList.Add(templateFolder + match.Groups[1].Value);
            match = match.NextMatch();
        }

        attachmentFiles = (string[])pathList.ToArray(typeof(string));

        // Replace parameters
        template = Regex.Replace(template, "##([^#]+)##",
                                 new MatchEvaluator(delegate(Match m)
                                 {
                                     string value;
                                     if (m.Groups.Count < 2) return m.Groups[0].Value;
                                     return (parameters.TryGetValue(m.Groups[1].Value, out value)) ? value : m.Groups[0].Value;
                                 }));

        // Get body
        body = template;

        // Get subject
        regex = new Regex("<title>(.*)</title>");
        match = regex.Match(template);
        subject = match.Groups[1].Value;
    }
ASKER CERTIFIED SOLUTION
ExpertLogin_890

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros