Skip to content

Commit

Permalink
EWSv2 fix html body default behaviour (demisto#34226)
Browse files Browse the repository at this point in the history
EWSv2 fix html body default behaviour demisto#34226
  • Loading branch information
DinaMeylakh authored May 16, 2024
1 parent 4ba751f commit 3bb77ce
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def get_message_for_body_type(body, body_type, html_body):
return HTMLBody(html_body) if html_body else Body(body)
if body_type.lower() == 'html' and html_body: # When called from 'send-mail' command.
return HTMLBody(html_body)
return Body(body)
return Body(body) if (body or not html_body) else HTMLBody(html_body)


def send_email_reply_to_mailbox(account, in_reply_to, to, body, subject=None, bcc=None, cc=None, html_body=None,
Expand Down
4 changes: 2 additions & 2 deletions Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,9 @@ script:
- name: replyTo
description: The email address specified in the 'reply to' field.
- name: body
description: The contents (body) of the email to send.
description: The contents (body) of the email to send. This argument overrides the "htmlBody" argument if the "bodyType" argument is Text.
- name: htmlBody
description: HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument.
description: HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument if the "bodyType" argument is HTML.
- name: bodyType
description: Whether message response body type is Text, or HTML.
auto: PREDEFINED
Expand Down
12 changes: 12 additions & 0 deletions Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,18 @@ def test_get_message_for_body_type_text_body_type_with_no_html_body():
assert result == Body(body)


def test_get_message_for_body_type_text_body_type_with_html_body_no_body():
"""
Given: html_body, no body, the default 'text' as body_type.
When: Constructing the message body.
Then: Assert that the result is an html body.
"""
html_body = "<p>This is an HTML body</p>"
result = get_message_for_body_type('', 'text', html_body)
assert isinstance(result, HTMLBody)
assert result == HTMLBody(html_body)


def test_parse_physical_address():
assert parse_physical_address(PhysicalAddress(city='New York',
country='USA',
Expand Down
5 changes: 3 additions & 2 deletions Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1719,13 +1719,14 @@ Sends an email using EWS.
| bcc | A CSV list of email addresses for the 'bcc' field. | Optional |
| subject | Subject for the email to be sent. | Required |
| replyTo | The email address specified in the 'reply to' field. | Optional |
| body | The contents (body) of the email to send. | Optional |
| htmlBody | HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument. | Optional |
| body | The contents (body) of the email to send. This argument overrides the "htmlBody" argument if the "bodyType" argument is Text. | Optional |
| htmlBody | HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument if the "bodyType" argument is HTML. | Optional |
| attachIDs | A CSV list of War Room entry IDs that contain files, and are used to attach files to the outgoing email. For example: attachIDs=15@8,19@8. | Optional |
| attachNames | A CSV list of names of attachments to send. Should be the same number of elements as attachIDs. | Optional |
| attachCIDs | A CSV list of CIDs to embed attachments within the email itself. | Optional |
| raw_message | Raw email message from MimeContent type. | Optional |
| from | The email address from which to reply. | Optional |
| bodyType | Whether message response body type is Text or HTML. Default is Text. | Required |


#### Context Output
Expand Down
6 changes: 6 additions & 0 deletions Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### EWS v2

Fixed an issue where providing `htmlBody` and not providing `body` arguments to the ***send-mail*** command resulted in an empty email body for the default `bodyType`.
2 changes: 1 addition & 1 deletion Packs/MicrosoftExchangeOnPremise/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Microsoft Exchange On-Premise",
"description": "Exchange Web Services",
"support": "xsoar",
"currentVersion": "2.1.5",
"currentVersion": "2.1.6",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 3bb77ce

Please sign in to comment.