Author Topic: smtp.send - how to send a hyperlink?  (Read 5408 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
smtp.send - how to send a hyperlink?
« on: July 14, 2015, 02:09:19 PM »
I'm working on a command similar to Nime5ter's Reuters World News

but with my command its giving more of a synopsis of the article so I want to email my self the link so I can read the full article later, but some of the url's can be quite long, so I've tried to Hyper link them using smtp.send but it seems like its sending text only,

these are what I have tried but with no luck
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.1-->
<command id="1169" name="Gmail Hyperlink Test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>The Blaze Headline</param>
      <param>&lt;a href="http://www.theblaze.com/"&gt;hey hey&lt;/a&gt; </param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>The Blaze Headline</param>
      <param>[url=http://www.theblaze.com/]hello world[/url]</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

and this is what the two emails look like
Quote
<a href="http://www.theblaze.com/">hey hey[/url]

[.url=http://www.theblaze.com/]hello world[/url]
^ I Added the period to break the link (it's not sent in the email)

is there a way to send hyperlink text using smtp.send?

Thanks



 



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #1 on: July 14, 2015, 04:24:21 PM »
I will add an optional parameter (boolean) to SMTP.Send so you can request that it send the message as HTML.

Next release.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: smtp.send - how to send a hyperlink?
« Reply #2 on: July 14, 2015, 04:36:25 PM »
Sweet Thanks  :D

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #3 on: July 14, 2015, 04:56:30 PM »
Would you like a Python solution in the meantime?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: smtp.send - how to send a hyperlink?
« Reply #4 on: July 14, 2015, 05:24:42 PM »
if its not to much trouble  ;D

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #5 on: July 14, 2015, 05:34:18 PM »
Not much trouble, no. :) I'd just be grabbing something already out there and making minor adaptations.

Do you already use other Python scripts? Can I just post a script here or would you prefer I also include the VC command for loading the script when VC launches?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: smtp.send - how to send a hyperlink?
« Reply #6 on: July 14, 2015, 05:39:14 PM »
Surprisingly I don't have any python scripts,  so I would need a command to load the script as well,

 Thank you!!

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #7 on: July 14, 2015, 05:54:00 PM »
No problem. I think the following should work, but let me know if not.

VC command group (some more instructions in the commands):

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.0-->
<commandGroup open="True" name="Python gmail smtp solution" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="597" name="Use this action instead of SMTP.Send" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="If you're passing variables from previous actions, be sure to keep them in the quotes. &#xD;&#xA;e.g. sendHTMLmsg ('{Match.1.1}','{Match.1.2}','{LastResult}') or whatever it may be.">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>sendHTMLmsg('your email subject line', 'URL for your newssite goes here', 'text you want to see in email instead of URL')</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="598" name="load the script" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Put gmail_SMTP.py file in your VoxCommando\PY folder. This command will load the script when VC loads.">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\gmail_SMTP.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
</commandGroup>

Python file is attached and should go in your VoxCommando\PY folder in order to work properly with the VC.Loaded command I included above. I'm including it here as well in a code box, though, for whoever wants the reference.

You should open the script in the Python plugin's editor so that you can enter your username,pwd,me,you info.

Code: [Select]
##Adapted from http://stackoverflow.com/questions/882712/sending-html-email-using-python##

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

username = "enter your gmail username"
pwd = "enter your gmail password"
me = "enter a sender email address"
you = "enter a recipient email address"

def sendHTMLmsg(subject, URL, link_text):

# Create message container - the correct MIME type is multipart/alternative.
    msg = MIMEMultipart('alternative')
    msg['Subject'] = subject
    msg['From'] = me
    msg['To'] = you

    # Body of HTML message (your article link)
    body = "<html><body><a href="+URL+">"+link_text+"</a></body></html>"

    # Set MIME type of body string to text/html.
    html = MIMEText(body, 'html')

    # Attach to message container.
    msg.attach(html)

    # Send the message via local SMTP server.
    mail = smtplib.SMTP('smtp.gmail.com', 587)

    mail.starttls()

    mail.login(username, pwd)
    mail.sendmail(me, you, msg.as_string())
    mail.quit()

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: smtp.send - how to send a hyperlink?
« Reply #8 on: July 14, 2015, 06:21:12 PM »
 ::bow :hugs :yay, it works, Thank you so much,

 the command that I'm building is based off your Reuters World News, but I wanted to use TheBlaze.com but they use A LOT of hyperlinks, social media links, and youtube videos so it would take 20 min to read one paragraph so I'm using Results.RegexReplace to drop all the extra but I loose some parts of the article, so it reads more of a synopsis of the article, so I want it to Email me a link to the articles I Choose so I can read the Articles that caught my attention,

With the youtube videos I have it skip the article and just launch the youtube video in XBMC (since most articles that contain a video are basically a transcript of the video)

Thanks Again


nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #9 on: July 14, 2015, 09:25:54 PM »
Sounds fancy!  :D

I'm going to move this thread now, as I just realized it's on the Plugins board.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: smtp.send - how to send a hyperlink?
« Reply #10 on: August 08, 2015, 03:14:27 AM »
I noticed that there is now an option for HTML using SMTP.Send  :D but I'm not having any luck using it, could I get an example of how to use it,
here is a couple of what I have tried
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.7-->
<command id="779" name="smtp test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>Html test</param>
      <param>&lt;a href="http://www.google.com"&gt;This is a link to Google&lt;/a&gt;</param>
      <param />
      <param>true</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>Html test</param>
      <param>&lt;a href="http://www.google.com"&gt;Google&lt;/a&gt;</param>
      <param />
      <param>true</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>Html test</param>
      <param>[url=http://www.google.com]hello[/url]</param>
      <param />
      <param>true</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>Html test</param>
      <param>http://www.google.com</param>
      <param />
      <param>true</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SMTP.Send</cmdType>
    <params>
      <param>@gmail.com</param>
      <param>Html test</param>
      <param>hello</param>
      <param />
      <param>true</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

all of them fail and say
Quote
Error: The path is not of a legal form

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #11 on: August 08, 2015, 08:29:35 AM »
You're not crazy, it's a small but unfortunate bug to do with the new attachment parameter that was added to SMTP.Send around the same time as the html boolean option. Thanks for pointing it out.

Setting the html parameter to true will work if you also add an attachment (basically it is expecting a file path in the "add attachment" parameter because you've entered a value in the subsequent parameter). Obviously, that's not the way it should be.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #12 on: August 08, 2015, 10:50:40 AM »
Sorry about that.  Already fixed and ready for the next release.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: smtp.send - how to send a hyperlink?
« Reply #13 on: October 16, 2015, 05:54:49 PM »
@PegLegTV -- in case you didn't catch the news, the long-awaited VC update -- 2.2.0.9 -- was released earlier today, and includes the SMTP.Send fix.

http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Version_2.2.0.9

Amen  ::)
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: smtp.send - how to send a hyperlink?
« Reply #14 on: October 16, 2015, 06:14:53 PM »
 Sweet 8), Thanks for the heads up,

hopefully I'll get some time to test it out today, I'm working on the tutorials for the home control app, so far the first video is a LOT of information packed in to a 15 minute video