我正在使用Microsoft图形包在laravel 5.4中使用Outlook Rest API V1.0。只是需要知道我如何使用Outlook创建消息API(api / v1.0 / me / sendemail)来发送多个收据。
还要让我知道php / laravel v2.0中有可用的软件包。
使用此代码段。
$subject = "any thing "; $to = "demo@email.com", $content = "Hi this is demo";
{ "Message":
{ "Subject": $subject,
"Body": { "ContentType": "Text", "Content": $content },
"ToRecipients": [ { "EmailAddress": { "Address": $to, } } ],
"Attachments": [ {
"@odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt", "ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk=" } ] },
"SaveToSentItems": "false"
}
答案 0 :(得分:0)
答案是,要在多个地址上发送电子邮件,您需要使用这种格式
"ToRecipient" => array(
array(
"EmailAddress"=>array(
"Address"=>'first_email@emailcom',
)
),
array(
"EmailAddress"=>array(
"Address"=>"second_email@email.com",
)
),
),
所以我们需要像这样动态地制作这种格式
$emails = 'first_email@email.com,second_email@email.com';
$to = explode(',',$emails);
if(count($to) > 1 )
{
foreach($to as $t){
$a[] = array('EmailAddress'=>array('Address'=>$t));
}
}else
{
$a[] = array('EmailAddress'=>array('Address'=>$emails));
}
然后像这样简单地将$ a传递到“ ToRecipient”对象中
"ToRecipient"=>$a
完成。