I have an application which reads the source html and downloads all the attachments of an email. This works fine except for the fact that Microsoft Outlook has some weird source value, for example...
<img width="163" height="39" id="Picture_x0020_1" src="cid:[email protected]" alt="Description: Description: Description: cid:[email protected]">
Firstly, I'd like to change it to just Attachments\image001.png as the source. Also, the alt should just be image001.png, not this long weird alt. Not really sure how to go about this.
You should use Regex (I updated the tags in your question to reflect this):
Regex.Replace(text, @"src=""cid:(?<FileName>[^@]+)@[^""]*""", @"src=""Attachments\${FileName}""",
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
Regex.Replace(x, @"alt=""[^.]*cid:(?<FileName>[^@]+)@[^""]*""", @"alt=""${FileName}""",
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
I'm sure there are more efficient ways of doing this, but that's what I could come up with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With