Is there a way to send an attachment on an email without having to save the file? I know how to create a file in a stream and later attach it to an email using a normal c# process, but all the email activities in UiPath only accept a string with the file path on the attached files.
Yes, I agree it is a straightforward method, but there are cases when you don’t want to or can’t use the file system.
Like in our case, we want to create a process to generate an SSRS report as a PDF to send via email to the user. We don’t need the file after that, and in fact, we don’t have access to the server’s file system. That’s why we want to create the file in memory and attach it to the email using a file stream.
@labrego what e-mail provider are you using? One possible way which came to my mind is to simply use Invoke code as there isn’t any activity of that kind for attachments.
If you’re using Outlook/O365 API (or any POP3/IMAP configuration), you can try to use MailMessage object to save the attachment in a variable.
@artur.stepniak, I am using the SMTP email provider, but I can use Outlook/O365 too. Your suggestion about using the MailMessage object sounds interesting, but the problem comes when you want to pass that variable to the email activity.
I was trying to avoid writing a custom activity, but it seems that will be the only solution.
You know, that’s the kind of mentality I want to learn. Sometimes, as a developer, I think about writing everything or using code to do every task. That changes with UIPath, and probably that’s the beauty of this thing; you end up learning to view and approach your job from a different perspective.
Yeah, that’s the beauty. I’ve been also thinking this way at first, but I’ve changed the approach and it’s faster and more reliable. And of course - cleaner.