Connecting Tech Pros Worldwide Forums | Help | Site Map

Adding attachment to mobile email application

Member
 
Join Date: Nov 2008
Location: UK
Posts: 117
#1: Mar 30 '09
Hi there.

I am developing a mobile device application which has an OpenFileDialog control which copies an image into a PictureBox, code as follows:

Expand|Select|Wrap|Line Numbers
  1. try
  2.  
  3. {
  4.  
  5. OpenFileDialog open = new OpenFileDialog(); 
  6. open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
  7.  
  8. if (open.ShowDialog() == DialogResult.OK) 
  9. {
  10.  
  11. pbImage.Image = new Bitmap(open.FileName);pbImage.SizeMode = PictureBoxSizeMode.CenterImage; 
  12. }
  13.  
  14. }
  15.  
  16. catch (Exception) 
  17. {
  18.  
  19. throw new ApplicationException("Failed loading image"); 
  20. }
  21.  
  22.  
That all works fine but what I also want to do is to email this image as an attachment of an email. This email functionality is within another Button click event as other fields in the mobile device form are included in the email as text.

Can anybody suggest some way(s) I can use to capture this image as an attachment, as well as displaying it in a picture box please?

Thank you.

M :o)

Member
 
Join Date: Nov 2008
Location: UK
Posts: 117
#2: Mar 31 '09

re: Adding attachment to mobile email application


I was able to solve this one. Simply a case of setting a string variable to ve equal to the open.FileName value in the code above, then instantiating a new Attachment and passing this the respective string value in the constructor.

All done.

Thank you.

Mark :o)
Reply