• 追加された行はこの色です。
  • 削除された行はこの色です。
Palm標準のMailを使って、他のアプリからメールを送る方法。

#contents

*送信トレイに入れる

-起動コード:[[sysAppLaunchCmdAddRecord:http://www.palmos.com/dev/support/docs/palmos/AppLaunchCodes.html#1011469]]。
-パラメータブロック:[[MailAddRecordParamsType:http://www.palmos.com/dev/support/docs/palmos/AppLaunchCodes.html#1011483]]

サンプル
-パラメータ
--宛先:mailTo
--件名:subject
--本文:body

 UInt16		cardNo;
 LocalID		dbID;
 Char		*string;
 DmSearchState	state;
 MailAddRecordParamsType *cmdPBP;
 
 if (DmGetNextDatabaseByTypeCreator (true, &state,
     sysFileTApplication, 'mail', true, &cardNo, &dbID);
     sysFileTApplication, 'mail', true, &cardNo, &dbID)
     != dmErrCantFind)
 {
  cmdPBP =
  (MailAddRecordParamsType *)MemPtrNew (sizeof(MailAddRecordParamsType));
  if (cmdPBP)
  {
   string = (Char *)MemPtrNew (StrLen (mailTo)
                             + StrLen (subject)
                             + StrLen (body)+ 3); 
   if (string)
   {
    StrPrintF (string, "%s%c%s%c%s%c",
               mailTo, chrNull, subject, chrNull, body, chrNull);
 
    cmdPBP->secret = false;
    cmdPBP->signature = true;
    cmdPBP->confirmRead = false;
    cmdPBP->confirmDelivery = false;
    cmdPBP->priority = mailPriorityNormal;
    cmdPBP->padding = 0;
    cmdPBP->subject = string + StrLen (mailTo) + 1;
    cmdPBP->from = "";
    cmdPBP->to = string;
    cmdPBP->cc = "";
    cmdPBP->bcc = "";
    cmdPBP->replyTo = "";
    cmdPBP->body = string + StrLen (mailTo) + StrLen (subject) + 2;
 
    if (MemPtrSetOwner (cmdPBP, 0) == errNone
     && MemPtrSetOwner (string, 0) == errNone)
     SysAppLaunch (cardNo, dbID, 0,
                   sysAppLaunchCmdAddRecord, cmdPBP, &result);
    MemPtrFree (string);
   }
   MemPtrFree (cmdPBP);
  }
 }

*下書きトレイに入れる

-起動コードは[[sysAppLaunchCmdGoToURL:http://www.palmos.com/dev/support/docs/palmos/AppLaunchCodes.html#1012191]]。
-パラメータブロックは文字列。書式はHTML形式。~
本来は、
 mailto:aaa@bbb.com?subject=件名&body=本文
だが、これだとmailto以外のパラメータが入ったときに上手くいかないので、
 mailto:?=&to=aaa@bbb.com &subject=件名 &body=本文
とした方が良さそう(?)

サンプル
 UInt16		cardNo;
 LocalID		dbID;
 DmSearchStateType state;
 UInt32		result;
 Char		*cmdPBP;
 Char		gotoURLString[] = "mailto:?=&to=%s &subject=%s &body=%s "
 
 if (DmGetNextDatabaseByTypeCreator(true, &searchInfo,
 if (DmGetNextDatabaseByTypeCreator(true, &state,
     sysFileTApplication, 'mail', true, &cardNo, &dbID)
     != dmErrCantFind)
 {
  cmdPBP = (Char *)MemPtrNew (StrLen (gotoURLString)
                            + StrLen (mailTo)
                            + StrLen (subject)
                            + StrLen (body) + 1);
  if (cmdPBP)
  {
   StrPrintF (cmdPBP, gotoURLString, mailTo, subject, body);
   if (MemPtrSetOwner(cmdPBP, 0) == errNone)
    SysAppLaunch (cardNo, dbID, 0, sysAppLaunchCmdGoToURL, cmdPBP, &result);
   MemPtrFree (cmdPBP);
  }
 }