CON-1273 - Email workflow with attachments/media uploaded to Azure Blob Storage - Throws Exception

Created by Warren Buckley 24 Feb 2017, 10:39:30 Updated by Claus Jensen 20 Mar 2018, 08:55:03

Duplicates: CON-1252

This is based from a discussion on CON-1056

I have a form with a File Upload. The image is uploaded in azure blob but Umbraco Forms looks on local disk and of course the image is not there and I got an error (on sending email workflow)

This is the error, but it's clear what's the issue:

There was a problem sending an email to 'myemail@yahoo.com' from Workflow for Form 'Form test' with id '910f6d62-f344-47fc-ae94-fdd31508ac24' for Record with unique id '7114907a-0414-414e-812d-bced4dc15b18'

System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\home\site\wwwroot\media\forms\upload\form_910f6d62-f344-47fc-ae94-fdd31508ac24\161b54bd-7753-4fd6-a29c-48812cb6e4d5\topics.png'.
 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
 at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
 at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
 at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, String mediaType)
 at System.Net.Mail.Attachment..ctor(String fileName)
 at Umbraco.Forms.Core.Providers.WorkflowTypes.SendEmail.Execute(Record record, RecordEventArgs e)

Comments

Florin Lazau 24 Feb 2017, 11:52:38

I am using Umbraco forms 4.4.0 and Umbraco 7.4.3.

Thanks, Florin


Lukas Vorlicek 20 Mar 2017, 13:11:55

We have the same problem in Umbraco 7.5.6 + UmbracoForms 4.4.2.

Attachment is saved to Azure storage and is available for download in "Entries" module, but "Send email" workflow fails everytime the "Attach file uploads to email" option is used.

2017-03-20 12:54:04,716 [P11812/D5/T25] ERROR Umbraco.Forms.Core.Providers.WorkflowTypes.SendEmail - There was a problem sending an email to 'xxxxxxx@xxxxxx.xxx' from Workflow for Form XXXXXX' with id '4e684170-b482-41a1-beaf-80af26abcf6a' for Record with unique id '00ed4f04-5f2f-4ee0-b836-c1ed3266eb42' System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\home\site\wwwroot\media\forms\upload\form_4e684170-b482-41a1-beaf-80af26abcf6a\3d1a26e0-8353-431e-ace8-2cac73c8b8b8_blank.doc'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, String mediaType) at System.Net.Mail.AttachmentBase..ctor(String fileName) at System.Net.Mail.Attachment..ctor(String fileName) at Umbraco.Forms.Core.Providers.WorkflowTypes.SendEmail.Execute(Record record, RecordEventArgs e)


Dave Woestenborghs 31 Aug 2017, 13:51:46

I think this because they are using Server.MapPath to get the file.

I create my own workflow and read the attachment like this var virtualFile = HostingEnvironment.VirtualPathProvider.GetFile(pathTofile);

                                var attachment = new Attachment(virtualFile.Open(), virtualFile.Name);
                                message.Attachments.Add(attachment);


Claus Jensen 20 Mar 2018, 08:55:03

I've put a App_Code fix for this issue in the duplicated issue: CON-1252


Priority: Normal

Type: Bug

State: Duplicate

Assignee:

Difficulty:

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 4.4.0

Due in version:

Sprint:

Story Points:

Cycle: