feat(CRM): Email Group Option In Email Campaign (#22731)
* new parent updating logic, made requested changes * feat: adding Email Group option in Email Campaign * fix: inv commas
This commit is contained in:
parent
d05a98517d
commit
cb45836cda
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"actions": [],
|
||||||
"autoname": "format:MAIL-CAMP-{YYYY}-{#####}",
|
"autoname": "format:MAIL-CAMP-{YYYY}-{#####}",
|
||||||
"creation": "2019-06-30 16:05:30.015615",
|
"creation": "2019-06-30 16:05:30.015615",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@ -52,7 +53,7 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Email Campaign For ",
|
"label": "Email Campaign For ",
|
||||||
"options": "\nLead\nContact",
|
"options": "\nLead\nContact\nEmail Group",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -70,7 +71,8 @@
|
|||||||
"options": "User"
|
"options": "User"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2019-11-11 17:18:47.342839",
|
"links": [],
|
||||||
|
"modified": "2020-07-15 12:43:25.548682",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "CRM",
|
"module": "CRM",
|
||||||
"name": "Email Campaign",
|
"name": "Email Campaign",
|
||||||
|
@ -70,10 +70,15 @@ def send_email_to_leads_or_contacts():
|
|||||||
send_mail(entry, email_campaign)
|
send_mail(entry, email_campaign)
|
||||||
|
|
||||||
def send_mail(entry, email_campaign):
|
def send_mail(entry, email_campaign):
|
||||||
recipient = frappe.db.get_value(email_campaign.email_campaign_for, email_campaign.get("recipient"), 'email_id')
|
recipient_list = []
|
||||||
|
if email_campaign.email_campaign_for == "Email Group":
|
||||||
|
for member in frappe.db.get_list("Email Group Member", filters={"email_group": email_campaign.get("recipient")}, fields=["email"]):
|
||||||
|
recipient_list.append(member['email'])
|
||||||
|
else:
|
||||||
|
recipient_list.append(frappe.db.get_value(email_campaign.email_campaign_for, email_campaign.get("recipient"), "email_id"))
|
||||||
|
|
||||||
email_template = frappe.get_doc("Email Template", entry.get("email_template"))
|
email_template = frappe.get_doc("Email Template", entry.get("email_template"))
|
||||||
sender = frappe.db.get_value("User", email_campaign.get("sender"), 'email')
|
sender = frappe.db.get_value("User", email_campaign.get("sender"), "email")
|
||||||
context = {"doc": frappe.get_doc(email_campaign.email_campaign_for, email_campaign.recipient)}
|
context = {"doc": frappe.get_doc(email_campaign.email_campaign_for, email_campaign.recipient)}
|
||||||
# send mail and link communication to document
|
# send mail and link communication to document
|
||||||
comm = make(
|
comm = make(
|
||||||
@ -82,7 +87,7 @@ def send_mail(entry, email_campaign):
|
|||||||
subject = frappe.render_template(email_template.get("subject"), context),
|
subject = frappe.render_template(email_template.get("subject"), context),
|
||||||
content = frappe.render_template(email_template.get("response"), context),
|
content = frappe.render_template(email_template.get("response"), context),
|
||||||
sender = sender,
|
sender = sender,
|
||||||
recipients = recipient,
|
recipients = recipient_list,
|
||||||
communication_medium = "Email",
|
communication_medium = "Email",
|
||||||
sent_or_received = "Sent",
|
sent_or_received = "Sent",
|
||||||
send_email = True,
|
send_email = True,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user