问候, 我需要使用示例或确切的代码来完成此操作,因为我迷路了,对发送邮件一无所知
Function VBA2Telegram(token As String, ChatID As String)
Dim msg1 As String, PostMsgStr As String, PhotoPath As String,sUrl As String
Dim oHttp As Object, sHTML As String, PostPhotoStr As String, strPostData As String
msg1 = "Hello there"
PhotoPath = "C:\1123.jpg"
PostMsgStr = "https://api.telegram.org/bot" & token & "/sendMessage?chat_id=" & ChatID & "&text=" & msg1
PostPhotoStr = "https://api.telegram.org/bot" & token & "/sendPhoto?chat_id=" & ChatID & "&photo=" & PhotoPath
Set oHttp = CreateObject("MSXML2.XMLHTTP")
oHttp.Open "POST", PostMsgStr, False
oHttp.Send
'Here,, how to set the code to do the job of sending local photo to telegram!
oHttp.Open "POST", PostPhotoStr, False
oHttp.Send
sHTML = oHttp.ResponseText
Debug.Print sHTML
End Function
答案 0 :(得分:0)
要上传机器中的照片,不能对请求使用GET方法以及文件的路径,而应使用包含文件内容的多部分/表单数据形式发布表单:请参见documentation。
您可以搜索如何在vba中使用multipart / form-data。 link或stack overflow answer也可能为您提供帮助。