RE: Download and attach file into Email from Azure blob storage
You will have to first get the image from Blob, a sample code from this link :
https://community.dynamics.com/365/b/heralddyncrm/archive/2018/05/27/upload-and-download-files-in-azure-blob-using-c
var containerName = "testcontainerherbi";
string storageConnection = CloudConfigurationManager.GetSetting("BlobStorageConnectionString"); CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(storageConnection); CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = blobClient.GetContainerReference(containerName); CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference("uploadedfilename.ext");
MemoryStream memStream = new MemoryStream();
blockBlob.DownloadToStream(memStream);
You can convert the Memory Stream to Byte Array and use the following sample to create attachment for Email
ActivityMimeAttachment _sampleAttachment = new ActivityMimeAttachment
{
ObjectId = new EntityReference(Email.EntityLogicalName, _emailId),
ObjectTypeCode = Email.EntityLogicalName,
Subject = String.Format("Sample Attachment {0}", i),
Body = System.Convert.ToBase64String(Your Byte Array),
FileName = String.Format("ExampleAttachment{0}.txt", i)
};