html attachment in iphone

Discussion in 'iOS Programming' started by smsawant, Aug 3, 2009.

  1. smsawant macrumors newbie

    Joined:
    May 7, 2009
    #1
    i am attaching image in email.but how can we attach html file in email ?
    here is code by which i am attaching image file in an email.

    Code:
    	UIImage *artworkImage = viewImage;
    	NSData *artworkJPEGRepresentation = nil;
    	if (artworkImage) 
    	{
    		artworkJPEGRepresentation = UIImageJPEGRepresentation(artworkImage, 0.7);
    	}
    	if (artworkJPEGRepresentation)
    	{
    		[composeVC addAttachmentData:artworkJPEGRepresentation mimeType:@"image/jpeg" fileName:@"Image.jpg"];
    	}
    	[self presentModalViewController:composeVC animated:YES];
    	[composeVC release];
    
    
    How can we attach HTML in a same way.

    I don't want to set HTML as body ,i want to send HTML as attachment.

    kindly guide me regarding this issue.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Convert your HTML to an NSData-class object and then use that for the addAttachmentData: parameter (you'll need to adjust the mimeType as well).
     
  3. smsawant thread starter macrumors newbie

    Joined:
    May 7, 2009
    #3
    Code:
    
    NSData* htmlAttach = [NSData dataWithContentsOfFile:filepath];
    [composeVC addAttachmentData:htmlAttach
                        mimeType:@"text/html"
                        fileName:@"html-file.html"];
    
    i have tried this but it is not working. it shows HTML as attachment but does not show the output of that attached file.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    "Does not show the output"? Please explain.
     

Share This Page