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.
Welcome to uipath forum
Exactly and that’s way more easier when compared to the process of creating file stream
And as you said UiPath can take only filepath for attachments along the mail activities
Is there any specific reason like why we need to avoid filepath
Else I would suggest to go for that option as it is a simple and clear method
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.
I’d try to simply use multiple assign activities and send composed e-mail: SmtpClient.Send Method (System.Net.Mail) | Microsoft Learn
Not sure if custom activity is really necessary as it’s quite simple activity.
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.
Thanks for the idea, @artur.stepniak
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.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.