// url is cloud url. public UrlAttachment CreateAttachment(string url, string name) { var html = "<html><a href=\""+ url + "\">Attachment: "+name+"</a></html>"; var attachment = new UrlAttachment(); attachment.Name = name; attachment.Bytes = GetBytes( html); return attachment; }
public static string UploadFile(UrlAttachment attachment) { var container = BlobClient.GetContainerReference("ExchangeAttachments"); container.CreateIfNotExists(); var blobName = attachment.Account + ":" + attachment.Name + ":" + attachment.TimeStamp.ToShortTimeString(); var blobRef = container.GetBlockBlobReference(blobName); // do we *REALLY* want to delete? blobRef.DeleteIfExists(); using (var ms = new MemoryStream(attachment.Bytes)) { blobRef.UploadFromStream(ms); } var url = blobRef.Uri.AbsoluteUri; return url; }