1. ritesh desai
  2. PowerBuilder
  3. Wednesday, 8 July 2020 19:02 PM UTC

Can someone guide me how to send mail using google rest api.

I try with

Long ll_rtn
HttpClient lhc_Client

lhc_Client = Create HttpClient
CoderObject lco_code
lco_code = Create CoderObject

string ls_url
//ls_Url = "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=media"
ls_Url = "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send"
lhc_Client.SetRequestHeader ( "Content-Type", "message/rfc822" )
lhc_Client.SetRequestHeader ( "Accept", "application/json" )
//lhc_Client.SetRequestHeader ( "Content-Type", "application/json" )
lhc_Client.SetRequestHeader("Authorization", "Bearer ya29.a0AfH6SMCke-UZmdOuGq14PK6iNP3yFRM0c0f_WaDI0giDApe_YHHapJUFDxu8Aeks_-vYo6984SX0Z-OfAP8jrrqqmwyM7B-guDh1CYp1vJKyzq8nCEGrhvNYpf8z1BMNfvg9o1h1VUvjSbCq_x48WosKinAao_9O7As")

Blob lblb_data
String ls_Base64Str, ls_postdata, ls_Body

string ls_email_data
ls_email_data = "From: from@gmail.com\r\n" + "To: to@gmail.com\r\n" + "Date:Fri, 21 Nov 1997 09:55:06 -0600\r\n" + "Subject:Subject Text\r\n\r\n" + "The message text goes here"

lblb_data = Blob(ls_email_data)

CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject
ls_Base64Str = lnv_CoderObject.Base64UrlEncode(lblb_data)

ls_postdata = '{"raw": "' + ls_Base64Str + '"}'

ll_rtn = lhc_Client.sendrequest( "POST", ls_Url , ls_postdata)

If ll_rtn = 1 And lhc_Client.getresponsestatuscode( ) = 200 Then
ll_rtn = lhc_Client.GetResponsebody( ls_Body)
Else
MessageBox ( "", lhc_Client.getresponsestatusText( ) )
End If

If IsValid ( lhc_Client ) Then DesTroy ( lhc_Client )
If IsValid ( lco_code ) Then DesTroy ( lco_code )

 

but not success

Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Friday, 8 January 2021 20:33 PM UTC
  2. PowerBuilder
  3. # 1

Hi Ritesh,

 

At a high level, you first need to authenticate using OAuth2.0. You may find more info and some similar examples here: https://community.appeon.com/index.php/qna/q-a/google-drive-rest-api

 

Then you can use the Gmail REST API: https://developers.google.com/gmail/api/quickstart/dotnet

 

I hope this helps.

 

Regards,

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.