所以基本上我想要的是将两个数字相加并求和或求和。
这是我的代码:
const string PropTag = "http://schemas.microsoft.com/mapi/proptag/";
var filter = "@SQL=" + "\"" + PropTag
+ "0x0037001E" + "\"" + " ci_phrasematch " + "\'" + strFilter + "\'";
Outlook.Table table = inbox.GetTable(filter, Outlook.OlTableContents.olUserItems);
while (!table.EndOfTable)
{
Outlook.Row nextRow = table.GetNextRow();
try
{
Outlook.MailItem mi;
try
{
string entryId = nextRow["EntryID"];
var item = outlookNameSpace.GetItemFromID(entryId);
mi = (Outlook.MailItem)item;
}
catch (InvalidCastException ex)
{
Console.WriteLine("Cannot cast mail item, so skipping. Error: {0}", e);
continue;
}
//Extract the attachments here and archive or reply - put your logic here
}
catch (Exception e)
{
Console.WriteLine("An error occurred: '{0}'", e);
}
}
这是我尝试添加它们的部分。
if (isset($this->date_filed) && !empty($this->date_filed) && !empty($this->date_forwarded_to_cmt_contractor)) {
$date_forwarded_to_cmt_contractor = Carbon::createFromFormat('Y-m-d', $this->date_forwarded_to_cmt_contractor);
$date_filed = Carbon::createFromFormat('Y-m-d', $this->date_filed);
$interval = $date_filed->diff($date_forwarded_to_cmt_contractor);
$this->cst_to_cmt = $interval->format('%a' . ' ' . 'Days');
if ($this->status == 'RECTI03') {
$now = Carbon::now();
$date_forwarded_to_cmt_contractor = Carbon::createFromFormat('Y-m-d', $this->date_forwarded_to_cmt_contractor);;
$interval = $date_forwarded_to_cmt_contractor->diff($now);
$this->cmt_to_current_date = $interval->format('%a' . ' ' . 'Days');
}
$this->date_filed_to_current_date = $this->cst_to_cmt + $this->cmt_to_current_date;
}
但是我得到这个错误。为什么呢? :/
“遇到格式不正确的数值”
答案 0 :(得分:3)
将类型转换为integer
怎么样?
$this->date_filed_to_current_date = (int)$this->cst_to_cmt + (int)$this->cmt_to_current_date;
当您在字符串上使用逗号或其他任何非数字字符(例如,
或-
)时,您会收到通知格式不正确的数字遇到的值。最好在添加操作之前将其转换为整数类型。
工作演示: https://3v4l.org/DAcWa