How to set a CloudBlob as Attachment?

Answered How to set a CloudBlob as Attachment?

  • Wednesday, August 22, 2012 6:43 AM
     
     

    Hi Guys,

    I'm making a web application that sends emails with attachment, and the attachments will be coming from a BlobStorage as CloudBlob. The adding of attachment requires that the CloudBlob should be a stream before i could attach the said file from BlobStorage.

    Please help. Thanks!

All Replies

  • Wednesday, August 22, 2012 7:57 AM
     
     

    Can you explain this in a little bit more detail please? Not sure if I understand it correctly. You want your application to send emails with attachments which are stored in blob storage. However you would want your users to download the attachment using a link or something in the email or is it something else.

    Thanks

     
  • Wednesday, August 22, 2012 7:59 AM
     
     

    Hi..

    You can set CDN option for your blob data.

    after you can attachment CDN url to your email.

    Regards,

  • Wednesday, August 22, 2012 8:13 AM
     
     

    Hi..

    You can set CDN option for your blob data.

    after you can attachment CDN url to your email.

    Regards,

    Hi Sir,

    Can you explain much further or maybe links on how to do this.

    Thanks!!

  • Wednesday, August 22, 2012 8:14 AM
     
     

    Can you explain this in a little bit more detail please? Not sure if I understand it correctly. You want your application to send emails with attachments which are stored in blob storage. However you would want your users to download the attachment using a link or something in the email or is it something else.

    Thanks

     

    Well, I just want to attach a file coming from a BlobStorage.

  • Wednesday, August 22, 2012 8:18 AM
     
     Proposed

    You could read the blob from blob storage, save it as a local file and then attach that file in your email.

    • Proposed As Answer by Carlos Sardo Wednesday, August 22, 2012 9:11 PM
    •  
  • Wednesday, August 22, 2012 8:28 AM
     
     

    You could read the blob from blob storage, save it as a local file and then attach that file in your email.

    I already thought that but what I want is that, it will automatically be attached without manually downloading it. I don't know if that's possible but I don't want the user to see the downloading process or downloading the file to his/her machine.
  • Wednesday, August 22, 2012 8:32 AM
     
     

    I don't think it's possible. As suggested by @MahoMay, you could instead embed a link to your blob in your email instead of attaching the file. Email recipient would then click on that link and download the blob.

  • Wednesday, August 22, 2012 8:46 AM
     
     

    I don't think it's possible. As suggested by @MahoMay, you could instead embed a link to your blob in your email instead of attaching the file. Email recipient would then click on that link and download the blob.

    Do you have any idea on how to do this? or maybe links that might be helpful on doing this.
  • Wednesday, August 22, 2012 8:59 AM
     
     

    CloudBlob object has a URI property (http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storageclient.cloudblob.uri). For your blob, you can get the URI and embed it into your message text.


  • Wednesday, August 22, 2012 9:27 AM
     
     

    CloudBlob object has a URI property (http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storageclient.cloudblob.uri). For your blob, you can get the URI and embed it into your message text.


    But if I only use the URI of a Blob, it only views the file in a browser instead of downloading it.
  • Wednesday, August 22, 2012 9:19 PM
     
     Answered

    Hi JustDaemon,

    An Email Attachment is a computer file sent along with an email message. Therefore, if you wish to, programatically, send files stored in Windows Azure Blog Storage in an email message you need to write some code that first downloads this Blob and then write some more code to attach it to your MailMessage.

    You can find some c#/vb.net examples here:

    1. Download Blob - http://msdn.microsoft.com/en-us/library/windowsazure/ee772912.aspx

    2. Attach file in MailMessage - http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.attachments.aspx

    I am sure you can find even more examples.

    The other option is (Even more simple), like the other persons contributing for this thread said, is embeding a link in your email message, so that people that receive the email can download the file from Blob Storage.


    Best Regards,
    Carlos Sardo



  • Thursday, August 23, 2012 6:21 AM
     
     Answered

    Hi,

    My suggestion is instead of downloading and adding it as attachment etc.. may limit your solution if your mail server has file size limitations. It may not be a limitation now, infuture you will end with the limitation if you have to supply bigger size files.

    I recommend you to host a page or WCF service either on premise or cloud that serves the downloads to end customers. Send the service or page URL through mail and when user clicks on the link your application will start downloading file from blob and saves it to their local disk.

    This way you can overcome the permissions issues etc.. You can share the same file to multiple customers with shared access signatures. Take a look at this link to understand it.

    Take a look at this blog to get some sample code for the apprach I mentioned.

    I feel this is the sophisticated way to implement your solution.

    Hope it helps



    Please mark the replies as Answered if they help and Vote if you found them helpful.