Question: I have an email template

For example this

> 
> Hello @FirstName@ @LastName@
> 
> 
> 

I have an object that comes from a parameter with properties

I need to iterate all object properties and replace all words that matched the property name quoted with @@ with property value.

So, for example, I have an object with FirstName and LastName, I need to iterate this object property and change @FirstName@ and @LastName@ in email.

The style of object was like this

```
{'FirstName': 'Eugene', 'LastName': 'Sukhomlyn'}

```

And code for this was like this

```
return Regex.Replace(template, @"@(?<prop>\w+)@", m =>
    {
        var property = input.GetType().GetProperty(m.Groups["prop"].Value);

        if (property != null)
        {
            var value = property.GetValue(input);
            if (value != null)
                return value.ToString();
        }

        return "";
    });

```

But I changed model to this, so now it List of objects

```
[{'Key': 'FirstName', 'Value': 'Eugene'},{'Key': 'LastName', 'Value': 'Sukhomlyn'}]

```

So logic will be like this, I need to get Key value and find text to replace @FirstName@ in this example and replace it with Value.

How I can do this?

Answer: 
Try to use this for dowloading image from URL, it helps me a lot that code, even you got the download on notification bar. You can set the filename when calling

```
 public static void downloadImage(Context context, String filename, String downloadUrlOfImage){
        try{
            DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
            Uri downloadUri = Uri.parse(downloadUrlOfImage);
            DownloadManager.Request request = new DownloadManager.Request(downloadUri);
            request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
                    .setAllowedOverRoaming(false)
                    .setTitle("result_"+filename)
                    .setMimeType("image/jpeg") // Your file type. You can use this code to download other file types also.
                    .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
                    .setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES,File.separator+"TirunelveliParithabangal"+File.separator + filename + ".jpg");
            dm.enqueue(request);
            Log.d(TAG, "Image download started");
        }catch (Exception e){
            Log.d(TAG, "Image download failed.");
            Toast.makeText(context, "Image download failed: "+filename, Toast.LENGTH_SHORT).show();
        }
    }

```
If you want to use a library than

```
dependencies {
        implementation 'com.github.artjimlop:altex-image-downloader:'
    }

```

And use this code to download

```
AltexImageDownloader.writeToDisk(context, PICTURE_URL, NAME_FOLDER); //NAME_FOLDER is the name of the folder where you want to save the image.

```

Just get the url and replace it with `PICTURE_URL`