Jump to content

[UDF] Gmail API - Emails automation with AutoIt!


Ascer
 Share

Recommended Posts

2 hours ago, mBild said:

I send $sBody, but also with $sBodyHtml

if you look at the code, Local $aRet = gmailUsersMessagesSend($aRecipient, $sSubject, $sBody & $sBodyHtml, $sYourGmailAdress, $aToken, "Bearer", Default, $sAttachment) , you can see that there is no text or html. I'd format all as html to save the learning curve, or, https://www.google.com/search?q=email+body+format+rfc

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

11 hours ago, argumentum said:

if you look at the code, Local $aRet = gmailUsersMessagesSend($aRecipient, $sSubject, $sBody & $sBodyHtml, $sYourGmailAdress, $aToken, "Bearer", Default, $sAttachment) , you can see that there is no text or html. I'd format all as html to save the learning curve, or, https://www.google.com/search?q=email+body+format+rfc

Many thanks for that tip!!! That solved it!!!

Link to comment
Share on other sites

14 hours ago, Jos said:

Well, I am still not seeing any runable script so have no idea as I can't test unless I am going to spend time to code it myself.

Jos

Formatting the text file as html solved my problem... Many thanks for your help!!!

Link to comment
Share on other sites

  • 4 weeks later...

Everything worked fine for the last couple of weeks. Suddenly I get the error:

+++ Line: 148, Func: oAuth2RefreshAccessToken() -> Error durning reading $oHttp.ResponseText. Google must changed *json respond for this request.

Can you please help.

 

Many thanks!!!

Link to comment
Share on other sites

16 hours ago, mBild said:

Google must changed *json respond for this request.

yes and no. The spaces is the problem. patch this

Func _JsonValue($sString, $sStart, $sEnd, $iMode = 0, $bCase = False)
    $sString = StringStripWS($sString,8)
    $sStart = StringStripWS($sStart,8)
    $sEnd = StringStripWS($sEnd,8)

and that should take care of it.  ( untested as I have no internet, I'm tethering with my cell phone ) but it should work.  

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Hi,

Im trying to make a an Email Sender with attachment for daily Reporting. But sometimes, the email can't be sent because there is not Internet Connection.
Is there a way to add a function to resend after x hours / x days the email?


The ideia is to send daily email with a daily attachment, if the daily day/attch fails sending. resend after X time ( resets cooldown to resend is sent is ok), and send the next email day from last one sent until no more days needed to be sent. Days are identified by filename( file01_23112018.csv) in the attachment. The send email part is easy I guess. but the function around the resend is the one that is making my head going nuts.
Any help of to achieve this, some examples ?

Ty!

Link to comment
Share on other sites

  • 9 months later...

Hello, does anyone know how to get the info returned from the function gmailUsersMessagesList

I was just trying it out and got that there was no error in the execution of the function, but i wasn't able to retrieve the information i wanted afterwards. It's strange because I thought the array returned from the function was 2D, but when asked for any on the elements it contained i got this error (2nd image), and if i treated it as if it was only 1D the MsgBox text would just appear to be blank.

132.thumb.PNG.aa1cbf4e1b806fd0e3e743a7327673e4.PNG1342.thumb.PNG.b9f284cfaa9828c3290fce1647414ba7.PNG

Link to comment
Share on other sites

And another question, i was doing this only in order to get the ID from the last message and be able to then get his content with gmailUsersMessagesGet( , but i just realized that the content from the email received doesn't just get into an array or something so that you can try to work with it, but rather in a json document, is there any way so avoid having to work with the data manually?

Link to comment
Share on other sites

15 hours ago, antalgu said:

And another question......

Welcome to the forum @antalgu
The solution mat be at 
https://www.autoitscript.com/forum/topic/192422-udf-gmail-api-emails-automation-with-autoit/?do=findComment&comment=1408292
Try that and see if it works.
As far as doing something "manually", welcome to coding.

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...

hi dude i got 

+++ Line: 141, Func: oAuth2RefreshAccessToken() -> Error durning send request to Google. $oHttp.Status = 400
$oHttp.ResponseText = {
  "error": "invalid_grant",
  "error_description": "Bad Request"
}

and i dont find refresh token ?

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...

Hello.

I do use Auth2 to access to Gmail, all works properly, but credential token has an expiration. Anyone has been able to renew the token without requesting again the web page and else?.
I do need that automated.

Thank you.

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Can someone please help ?

Attached screenshots randomly arrive blank.

I tried to give 2 seconds delay after taking a screenshot, that kinda helped but i am still getting unreadable jpeg files.

I did not modify the UDF's or how i send the message.

I Simply take a screenshot before i send the email and then list it as an attachment.

Sometimes picture needs time to be created so i sleep. Otherwise blank emails can arrive

$PictureFile = (@ScriptDir & "\Sent\Snapshot" & $PicCount & ".jpg")
    _ScreenCapture_SetJPGQuality(50)  ;50% quality screenshot
    Sleep(500)
    _ScreenCapture_Capture($PictureFile) ;take screenshot
    Sleep(2000)
    
    
    $sAttachment = $PictureFile
    gmailUsersMessagesSend($aRecipient, $sSubject, $sBody & $sBodyHtml, $sYourGmailAdress, $aToken, "Bearer", Default, $sAttachment)

I get no errors. Message is sent but more often then not, picture is not readable, only text from body.

 

Dont get me wrong, picture does get attached and received. Sometimes its 0 in size, sometimes its few kb's matching exactly the size of the original but its blank.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...