Jump to content
Ascer

[UDF] Gmail API - Emails automation with AutoIt!

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

Share this post


Link to post
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!!!

Share this post


Link to post
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!!!

Share this post


Link to post
Share on other sites

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!!!

Share this post


Link to post
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.  

Share this post


Link to post
Share on other sites

it's says that the email has been sent sucessfully but i do not receive values in "meesageid" and "threadid"... and the email is not sent, what's happening?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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?

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AlienStar
      hello everybody 
      I need to automate uploading image via Autoit to my wordpress blog 
      here is my code 
      $url = "https://engnajjar.wordpress.com/wp-admin/media-new.php?browser-uploader" Local $oIE =_IECreate($url) Local $async_upload = _IEGetObjById($oIE, "async-upload") Local $upload_btn = _IEGetObjById($oIE, "html-upload") _IEAction($async_upload, "click") Sleep(1000) $hChoose = WinGetHandle("[CLASS:#32770]") WinWaitActive($hChoose, "Choose File to Upload", 10) ControlFocus($hChoose,"","Edit1") Sleep(1000) ControlSetText($hChoose, "", "Edit1", "C:\Users\administrator\Pictures\image.jpg") ControlClick($hChoose, "", "Button1") when the code open popup upload dialog it can't set image location text in edit box to select image 
      the code still wait popup upload dialog although the dialog is active.
      when I close the dialog, the code back to work then exit without detect the dialog.
      where is the problem in my code please ?
    • By tarretarretarre
      About AutoIt-API-WS
      AutoIt-API-WS is a light weight web server with expressive syntax, with the sole purpose of wrapping your existing AutoIt app with little to no effort.
      With AutoIt-API-WS you can send and receive data between any application or framework, as long they can handle HTTP requests, which is an industry standard today.
      Like my other communcations UDF AutoIt-Socket-IO AutoIt-API-WS is heavily inspired from the big boys, but this time its Laravel and Ruby on Rails.
      Features Highlights
      No external or internal dependencies required RESTful mindset when designed Expressive syntax Small codebase Heavy use of Michelsofts Dictionary object Limitations
      Not complient with any RFC, so something important could be missing. Time will tell! One persons slow loris attack will kill the process forever. Example of implemetnation (With screenshots)
      This is a basic cRud operation with the RESTful mindset in use.
      #include "API.au3" #include <Array.au3> _API_MGR_SetName("My APP DB adapter") _API_MGR_SetVer("1.0 BETA") _API_MGR_SetDescription("This adapter allows you to get this n that") _API_MGR_Init(3000) _API_MGR_ROUTER_GET('/users', CB_GetUsers, 'string sortBy', 'Get all users, sortBy can be either asc or desc. asc is default') _API_MGR_ROUTER_GET('/users/{id}', CB_GetUsersById, 'int id*', 'Get user by id') While _API_MGR_ROUTER_HANDLE() WEnd Func DB_GetUsers() Local $userA = ObjCreate("Scripting.Dictionary") Local $userB = ObjCreate("Scripting.Dictionary") $userA.add('id', 1) $userA.add('name', 'TarreTarreTarre') $userA.add('age', 27) $userB.add('id', 2) $userB.add('name', @UserName) $userB.add('age', 22) Local $aRet = [$userA, $userB] Return $aRet EndFunc Func CB_GetUsers(Const $oRequest) Local $aUsers = DB_GetUsers() If $oRequest.exists('sortBy') Then Switch $oRequest.item('sortBy') Case Default Case 'asc' Case 'desc' _ArrayReverse($aUsers) EndSwitch EndIf Return $aUsers EndFunc Func CB_GetUsersById(Const $oRequest) Local Const $aUsers = DB_GetUsers() Local $foundUser = Null For $i = 0 To UBound($aUsers) -1 Local $curUser = $aUsers[$i] If $curUser.item('id') == $oRequest.item('#id') Then $foundUser = $curUser ExitLoop EndIf Next If Not IsObj($foundUser) Then Return _API_RES_NotFound(StringFormat("Could not find user with ID %d", $oRequest.item('#id'))) EndIf return $foundUser EndFunc When you visit http://localhost:3000 you are greeted with this pleasent view that will show you all your registred routes and some extra info you have provided.

      When you visit http://localhost:3000/users the UDF will return the array of objects as Json
       
      And here is an example of http://localhost:3000/users/1

       
      More examples can be found here
       
       
      Autoit-API-WS-1.0.0-beta.zip (OLD!)
      Autoit-API-WS-1.0.1-beta.zip (NEWEST 2020-06-29)
    • By nacerbaaziz
      goodmorning autoit team
      today am comming with some winhttp problems, i hope that you can help me to solve them.
      the first problem
      is when opening a request
      my forums api allow me to delete any post using the api key
      all functions work, i mean post / get
      but when i tried to use the delete verb it's gave me an html 404 error
      here is what am tried
      #include "WinHttp.au3" ; Open needed handles Global $hOpen = _WinHttpOpen() Global $hConnect = _WinHttpConnect($hOpen, "xxxxxxxx.com") ; Specify the reguest: Global $hRequest = _WinHttpOpenRequest($hConnect, "Delete", "/vb/Api/posts/10447/?hard_delete=true", default, default) _WinHttpAddRequestHeaders($hRequest, "XF-Api-Key:xxxxx") _WinHttpAddRequestHeaders($hRequest, "XF-Api-User:xxxxx") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Global $sHeader = 0, $sReturned = 0 ; If there is data available... If _WinHttpQueryDataAvailable($hRequest) Then $sHeader = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_DISPOSITION) ;Or maybe: ; $sHeader = _WinHttpQueryHeaders($hRequest, BitOR($WINHTTP_QUERY_RAW_HEADERS_CRLF, $WINHTTP_QUERY_CUSTOM), "Content-Disposition") Do $sReturned &= _WinHttpReadData($hRequest) Until @error msgBox(64, "", $sReturned) endIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)  
      and here is the error message
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /vb/Api/posts/10447/ on this server.<br /> </p> </body></html>  
      i hope you can help me 
      thanks in advance
    • By argumentum
      I can TCP/IP in AutoIt, hence, make a HTTP deamon. Now, how can I HTTPS to use SSL !??
      Well, Apache has this "mod_proxy.so" module that can let me have SSL and what not is in Apache.
      All that is needed is to tell Apache what I wanna do by editing httpd.conf .
      # Implements a proxy/gateway for Apache. # 1. Open /Applications/XAMPP/etc/httpd.conf # 2. Enable the following Modules by removing the # at the front of the line. # - LoadModule rewrite_module modules/mod_rewrite.so # - LoadModule proxy_module modules/mod_proxy.so # - LoadModule proxy_http_module modules/mod_proxy_http.so # # 3. Copy and Paste below to the bottom of httpd.conf # <IfModule mod_proxy.c> ProxyRequests On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyVia Off ProxyPreserveHost Off ProxyPass /home/ http://127.0.0.1:84/home/ ProxyPassReverse /home/ http://127.0.0.1:84/home/ SetEnv proxy-nokeepalive 1 # ..since we are not using "keep-alive", we are using "close" </IfModule> ...et voila  
      I'm using XAMPP ( https://www.apachefriends.org/download.html )
      and this is my solution to avoid coding in PHP, as I feel more comfortable coding in AutoIt.
      A "muli-thread or concurrency" can be done by forking the socket ( https://www.autoitscript.com/forum/topic/199177-fork-udf-ish/ )
      but responses are under 20 ms., so I feel fine with a single thread.
      I modified an example ( attached below ), so can try out the concept.
      PS: I am not an Apache guru. I just discovered this and it opens a world of possibilities. In my case, I'm thinking of an API to query SQLite 
      PS2: I'm not gonna make Poll but do click like if you do  
       
      201673-json-http-post-serverlistener.au3
    • By MichaelSDeVries
      Has anyone successfully developed  integration with the E*TRADE API in AutoIt?


       
      If so, then would you be willing and able to share some of your AutoIt code to do so with me? and/or help me successfully develop an AutoIt interface with the E*TRADE API?

       
      Please also Reply at: http://blog.thevcf.com/forums/topic/etrade-api/#post-4032

       
      Thank You and Have a Great Day!
      - Michael S. DeVries
×
×
  • Create New...