Posts Tagged ‘send mail’
10
gen

Hi all,
with these lines of code you can use Apple iOS Mail system to send an email with an attachment!





It’s so easy that i don’t know this method!

First, import MessageUI framework, after include in your header file (.h) the import to the framework:

1
#import messageui/MessageUI.h

and set the delegate to

1
mfmailcomposeviewcontrollerdelegate

Now, create a button in your view and attach mailil function!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- (void) mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult: (MFMailComposeResult)result error:(NSError*)error {
 [self dismissModalViewControllerAnimated:YES];
}

- (IBAction) mailIt {
 MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
 picker.mailComposeDelegate = self;
 
 [picker setSubject:@"This is the subject"];
 
 UIImage *roboPic = [UIImage imageNamed:@"anImage.jpg"];
 NSData *imageData = UIImageJPEGRepresentation(roboPic, 1);
 [picker addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"anImage.jpg"];
 
 NSString *emailBody = @"This is the email body!!";
 [picker setMessageBody:emailBody isHTML:YES];
 
 [self presentModalViewController:picker animated:YES];
 [picker release];
}

done!





Rif: albertopasca.it

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , ,

23
lug

Come spedire una mail con C# .net?

Framework 2.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
using System.Web.Mail;

[...]

MailMessage mail = new MailMessage();

mail.To = "to@email.it";
mail.From = "da@email.it";
mail.Subject = "ciao!!!";
mail.BodyFormat = MailFormat.Html;
mail.Body = "<b>Testo</b> del messaggio!";

SmtpMail.SmtpServer = "tuo.smtp.com";
SmtpMail.Send(mail);


Framework 3.5:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Net.Mail;

[...]

MailMessage mail = new MailMessage();

mail.To.Add("mail0@site.it");
mail.CC.Add("mail1@site.it");
mail.CC.Add("mail2@site.it");

mail.From = new MailAddress("noreply@site", "NAME");
mail.Subject = "[AUTO] Mail automatica";

mail.Body = "(Mail automatica)\n\nTesto...";

SmtpClient smtp = new SmtpClient("smtp.site.it");

try { smtp.Send(mail); }
catch  { }

tutto qui!!!

[ref -> albertopasca.it]

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , ,

Switch to our mobile site