Dynamics CRM Plugin 傳送郵件

2021-08-26 09:29:21 字數 2346 閱讀 4222

1 建立郵件

/// 

/// 發件人的guid的list

/// 收件人的guid的list

/// 抄送人的guid的list

/// 需要傳送郵件的實體,可以根據此處獲取郵件中需要的資訊

///

private void createinformemail(iorganizationservice service, listfromemail, listtomail, listccmail, entity entity)

//收件人

foreach (guid to in tomail)

//抄送人

foreach (guid cc in ccmail)

string subjecttxt = string.empty;

string fname = entity.getattributevalue("new_name");

if (fname == null) fname = "";

var owner = entity.getattributevalue("new_business_owner");

string ownername = string.empty;

if (owner != null) ownername = owner.name;

entity eml = new entity("email");

eml.attributes["from"] = from_list.toarray();

eml.attributes["to"] = to_list.toarray();

eml.attributes["cc"] = cc_list.toarray();

eml["regardingobjectid"] = new entityreference(entity.logicalname, entity.id);

eml.attributes["actualdurationminutes"] = 30;

eml.attributes["isworkflowcreated"] = false;

//郵件主題

subjecttxt = fname + " 合同到期提醒 contract expiration reminder";

eml.attributes["subject"] = subjecttxt;

#endregion

#region 郵件模板

stringbuilder body = new stringbuilder();

string url = configutils.crmextenalurl + configutils.crmorganizationname + "main.aspx?etn=" + entity.logicalname + "&pagetype=entityrecord&id=%7b" + entity.id + "%7d";

eml.attributes["description"] = body.tostring();

#endregion

guid email_id = service.create(eml);

//return email_id;

//傳送

sendemailrequest sendemailreq = new sendemailrequest();

sendemailreq.emailid = email_id;

sendemailreq.trackingtoken = "";

sendemailreq.issuesend = true;

sendemailresponse sendemailresp = (sendemailresponse)service.execute(sendemailreq);

}catch (exception ex)

}

2.獲取需要發郵件的使用者

public guid getmailuserid(string strdomainname)

;parameters[0].value = strdomainname;

dataset ds = sqlhelper.executedataset(commandtype.text, sql, parameters);

guid g_ownerid = guid.parse(ds.tables[0].rows[0]["systemuserid"].tostring());

//entityreference ref_user = new entityreference("systemuser", g_ownerid);

return g_ownerid;

}

thinkPHP PHPMailer 傳送郵件

二 在thinkphp的配置檔案config.php中寫以下 郵件傳送配置 mail host smtp.163.com smtp伺服器的名稱 mail host smtp.exmail.qq.com 郵箱是qq mail smtpauth true,啟用smtp認證 mail username 1...

thinkphp phpmailer傳送郵件

1.在function.php中新增 郵件傳送函式 param address 郵件收件人位址 param titlle 郵件標題 param content 郵件內容 param attachment 附件 function sendmail addressee,title,content,att...

django celery redis 傳送郵件

broker是乙個訊息傳輸的中介軟體,可以理解為乙個郵箱。每當應用程式呼叫celery的非同步任務的時候,會向broker傳遞訊息,而後celery的worker將會取到訊息,進行對於的程式執行。好吧,這個郵箱可以看成是乙個訊息佇列。那麼什麼又是backend,通常程式傳送的訊息,發完就完了,可能都...