hi, How to attach a file(from external source) to an email.
I have a email function in C# and trying to send an attachment. If the attachment is within the project then its working. But if I upload/move the attachment to out of the project/application folder its gives error
"System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. :
How do i solve it ?
What I have tried:
MimeMessage messageClient = new MimeMessage();
messageClient.From.Add(new MailboxAddress("From Name", _config.GetSection("EmailUsername").Value));
messageClient.To.Add(MailboxAddress.Parse(ClientEmail));
messageClient.Subject = CleintSubject;
BodyBuilder bodyBuilder = new BodyBuilder();
bodyBuilder.HtmlBody = ClinetMailBody;
bodyBuilder.Attachments.Add(_env.WebRootPath + "\\downloads\\sample.pdf"); ==> Working
bodyBuilder.Attachments.Add(@"https://abc.com/assets/sample.pdf"); ==> Not working
Any thoughts ?