iPhoneってメール送信はmailtoしか用意してないんですね。それ以上のものを作る(長い文字列の送信など)には自分でSMTPクライアント作るしかないみたいです。
とりあえずmailtoを使ったアプリSendingEmailを作ってみました。

###作業

  1. プロジェクトの新規作成でView-Based Applicationを選択:SendingEmailとする
  2. SendingEmailViewControllerにsendingEmail関数を追加
  3. SendingEmailViewController.xibファイルをダブルクリックしてInterfaceBuilderを起動
  4. InterfaceBuilderで先ほど追加したsendingEmailとGUIをマッピング
  5. Build&Goして動作を確認します:エミュレータではメール送信画面は表示されませんので、実機でどうぞ

###UIViewControllerにsendingEmail関数を追加
SendingEmailViewController.hファイル
rails>>
@interface SendingEmailViewController : UIViewController {
}

  • (IBAction) sendingEmail: (id) sender;

@end
<<--

SendingEmailViewController.mファイル
rails>>
#import "SendingEmailViewController.h"

@implementation SendingEmailViewController

  • (IBAction)sendingEmail:(id)sender {
    NSURL* mailURL = [NSURL URLWithString: @"mailto:satoko@somedomain.com?subject=My%20Subject&body=bodyStuff"];
    NSLog(@"mailURL: %@", mailURL); //Debug [[UIApplication sharedApplication] openURL: mailURL];
    }
    <<--

###InterfaceBuilderでの作業:SendingEmailViewController.xibを編集

  1. Round Rect Button(UIBUtton)をview上にドロップしてtitleにsend Emailと入力
  2. File's Ownerを右クリックしてダイアログを開き(この黒いダイアログなんて呼ぶのかな...)
  3. File's OwnerのsendingEmail関数を、ボタンの関数Touch Up Insideと結びつける
  4. ダイアログ内のReceived Actions項のsendingEmailの右端の丸をクリック&ドラッグして、
  5. ステップ1.で置いたボタン上までマウスを持って行き
  6. ボタンがハイライトされたらマウスを放す
  7. ダイアログ内のTouch Up Insideを選択

sendingEmail_InterfaceBuilder.png

###注意
件名や本文はエンコードしないといけないようです。
http://eggbung.blogspot.com/2008/11/iphone-development-creating-email-with.html
http://www.iphonewebdev.com/examples/mailto.html

posted by satoko satoko on Thu 4 Dec 2008 at 16:52 with 0 comments

とりあえずサンプルは動いた。でも何がなんだかわからないという人はこれをやってみるといいかもしれません。

developer.apple.comのiPhone101
上記リンクの内容のpdf版

###学んだ・作業したこと

  • xibはニブ(nib)ファイルと読む
  • Delegatorとプロトコルがなんとなく
  • (初心者には便利な)Interface Builderを使ってのGUI作成

###できたアプリ
UITextFieldに名前を入力して、Helloボタンを押すと、"Hello, satoko!"と表示するアプリ
iPhone Simulator.png

posted by satoko satoko on Thu 4 Dec 2008 at 15:03 with 0 comments
Contents rssrss
Leading Smart TV App Development Companies | USA | 4 Way Technologies
Apple TV Developer | TVOS Development | USA | 4 Way Technologies
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Value Transformer
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Tags
iphone
Comments rssrss
瀧内元気 瀧内元気: MacOS版は以下にあります genki/ViMouse 01/16 05:40
KingofSmack KingofSmack: Here also good reads for this mobile application d... 05/10 18:02
Spencer Spencer: You don't have to re-compile it, this version work... 04/08 07:15
staiano staiano: Any chance we can get a recompile for 10.9? 01/10 01:47
dsjf dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これでも出... 01/08 23:23
yoku0825 yoku0825: nkfの方が使いやすいですが、glibcに含まれているiconvの方が 確実にどの環境にも入っている... 06/11 07:03
falsefalse falsefalse: @tiancongxin try using this one https://github.com... 02/14 08:04
瀧内元気 瀧内元気: おお、チェックしてみます。thx! 12/24 05:23
Services from s21g
YOMU Web小説リーダー
Web小説を音声で楽しむ読み上げリーダー
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
個人開発者のためのホスティング一体型ノートサービス
ハンドミラー
iPhone向けの手鏡アプリ
ツイプロ(twpro)
Twitterプロフィールの高速検索エンジン