Skip to content Skip to sidebar Skip to footer

Images As Email Attachment

I want to build an application where i am able to attach an image with the email, open the image and set it as my wallpaper. I wanted to make it cross platform so can you tell me i

Solution 1:

Hello if you want to just attach your image with email then using this code you can do this..

ArrayList<String> str = new ArrayList<String>() ;
ArrayList<Uri> uris = new ArrayList<Uri>();

//convert from paths to Android friendly Parcelable Uri'sfor(int i=0; i<ayy_Images.size(); i++)
{
   if(ayy_Images.get(i) == null)
    {
       str.add("");
    }
    else
    {
       str.add(ayy_Images.get(i));
    }
}

for (String file : str)
{
   File fileIn = new File(file);
   Uri u = Uri.fromFile(fileIn);
   uris.add(u);
}

startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND_MULTIPLE).setType("audio/wav").setType("image/jpeg").setType("message/rfc822")
                            .putExtra(Intent.EXTRA_EMAIL, emails)
                            .putExtra(Intent.EXTRA_SUBJECT, subject)
                            .putExtra(Intent.EXTRA_TEXT, strDetails).putExtra( android.content.Intent.EXTRA_STREAM, uris), "Send your email in:"));             

ayy_Images is a ArrayList which contains the list of images.

Solution 2:

For iPhone sdk you attach image as :

NSData*photoData =UIImageJPEGRepresentation([UIImage imageNamed:@"anImage.png"], 1);
MFMailComposeViewController*picker = [[MFMailComposeViewController alloc] init];
[picker addAttachmentData:photoData mimeType:@"image/jpg" fileName:[NSString stringWithFormat:@"image001.png"]];

For " open the image and set it as my wallpaper "

It is not possible via code in iPhone. You have to use the Settings.app

Post a Comment for "Images As Email Attachment"