notebook example does not work

1162
3
Jump to solution
11-12-2019 10:33 AM
JeffTimm
Occasional Contributor

I am going through the example notebook 

Content Management: Check for broken URLs

and it works fine other than the email output.  The assembly code says this:

# Asemble the message and return it
return f"Webmap ID '{webmap_item.id}' contains unreachable URLs."\
f"You can view the webmap here: {webmap_item.homepage}\n"\
f"\n"\
f"Reachable Layers\n"\
f"----------------->\n"\
f"{reachable_str}\n"\
f"\n"\
f"Unreachable Layers\n"\
f"------------------->\n"\
f"{unreachable_str}"

but the email sent has this in the email body:

Reachable Layers

----------------->

* World_Hillshade_3805

 

Unreachable Layers

------------------->

* plsstest_655

* CityCountyState_5586

Where is the first part and why does it not include that in the email?  Any ideas?

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Jeff Timm‌ , sorry we couldn't respond to this in time for GIS day demo. Happy to try to help you debug this now.

There are a few things that can be causing that message to get truncated. What email service are you using to send emails via SMTP? Sometimes different providers (gmail, yahoo mail, custom smtp servers) parse the body of the email in different ways. So you might have to look into your provider's documentation for programmatic sending of emails.

If I had to guess what you were running into, I'm guessing it's something weird with your email provider and newlines (your email starts with "Reachable Layers", the first line to be preceded by two newlines). I've seen similar behavior with newlines when I've run this code against different email providers. Can you try modifying your Python code to the following?

return f"This an email about an ArcGIS WebMap. (This line may get truncated).\n"\
f"\n"\
f"Webmap ID '{webmap_item.id}' contains unreachable URLs."\
f"You can view the webmap here: {webmap_item.homepage}\n"\
f"\n"\
f"Reachable Layers\n"\
f"----------------->\n"\
f"{reachable_str}\n"\
f"\n"\
f"Unreachable Layers\n"\
f"------------------->\n"\
f"{unreachable_str}"

I can't guarantee that will work, let me know if it doesn't!

- David

View solution in original post

3 Replies
JeffTimm
Occasional Contributor

I was hoping to demo this on GIS day! Tomorrow

0 Kudos
by Anonymous User
Not applicable

Hi Jeff Timm‌ , sorry we couldn't respond to this in time for GIS day demo. Happy to try to help you debug this now.

There are a few things that can be causing that message to get truncated. What email service are you using to send emails via SMTP? Sometimes different providers (gmail, yahoo mail, custom smtp servers) parse the body of the email in different ways. So you might have to look into your provider's documentation for programmatic sending of emails.

If I had to guess what you were running into, I'm guessing it's something weird with your email provider and newlines (your email starts with "Reachable Layers", the first line to be preceded by two newlines). I've seen similar behavior with newlines when I've run this code against different email providers. Can you try modifying your Python code to the following?

return f"This an email about an ArcGIS WebMap. (This line may get truncated).\n"\
f"\n"\
f"Webmap ID '{webmap_item.id}' contains unreachable URLs."\
f"You can view the webmap here: {webmap_item.homepage}\n"\
f"\n"\
f"Reachable Layers\n"\
f"----------------->\n"\
f"{reachable_str}\n"\
f"\n"\
f"Unreachable Layers\n"\
f"------------------->\n"\
f"{unreachable_str}"

I can't guarantee that will work, let me know if it doesn't!

- David

JeffTimm
Occasional Contributor

That worked! Thanks

0 Kudos