Sending Emai Attachments
- How-to
- mathews rutto
- PowerBuilder
- Tuesday, 3 December 2024 08:54 PM UTC
Hi, this code word perfectly but it's only sending one attachment and i need to send two attachments as indicated below.
Please help.
ls_item = 'abc.pdf'
ls_file = "D:\" + ls_item
ls_item2 = '123.xls'
ls_file2 = "D:\"+ ls_item2
//Read the file into a blob
ll_FileNum = FileOpen(ls_file,StreamMode!)
if ll_FileNum > 0 then
FileReadEx(ll_FileNum, blb_file)
FileClose(ll_FileNum)
else
MessageBox('File Error', 'Error Opening Filename ' + ls_file)
return
end if
// Read the file into a blob
ll_FileNum2 = FileOpen(ls_file2, StreamMode!)
if ll_FileNum2 > 0 then
FileReadEx(ll_FileNum2, blb_file1)
FileClose(ll_FileNum2)
else
MessageBox('File Error', 'Error Opening Filename ' + ls_file2)
return
end if
// Create component blobs
blb_multipart = blob('--' + ls_Boundary + '~r~n', EncodingUTF8!)
blb_multipart += blob('Content-Disposition: form-data; name="to"' + '~r~n~r~n' + ls_email + '~r~n', EncodingUTF8!)
blb_multipart += blob('--' + ls_Boundary + '~r~n', EncodingUTF8!)
blb_multipart += blob('Content-Disposition: form-data; name="subject"' + '~r~n~r~n' + ls_subject + '~r~n', EncodingUTF8!)
blb_multipart += blob('--' + ls_Boundary + '~r~n', EncodingUTF8!)
blb_multipart += blob('Content-Disposition: form-data; name="text"' + '~r~n~r~n' + ls_text + '~r~n', EncodingUTF8!)
blb_multipart += blob('--' + ls_Boundary + '~r~n', EncodingUTF8!)
blb_multipart += blob('Content-Disposition: form-data; name="cc"' + '~r~n~r~n' + ls_null + '~r~n', EncodingUTF8!)
blb_multipart += blob('--' + ls_boundary + '~r~n', EncodingUTF8!)
blb_multipart += blob('Content-Disposition: form-data; name="attachment1"; filename="'+ ls_item +'"~r~nContent-Type: application/*~r~n~r~n', EncodingUTF8!) + blb_file
blb_multipart += blob(ls_file, EncodingUTF8!)
blb_multipart += blob('--' + ls_boundary + '~r~n', EncodingUTF8!)
blb_multipart += blob('Content-Disposition: form-data; name="attachment2"; filename="'+ ls_item2 +'"~r~nContent-Type: application/*~r~n~r~n', EncodingUTF8!) + blb_file1
blb_multipart += blob(ls_file2, EncodingUTF8!)
blb_multipart += blob('~r~n--' + ls_Boundary + '--~r~n', EncodingUTF8!)
// Send the request
lnv_HttpClient = create HTTPClient
lnv_httpClient.SetRequestHeader("CM-API-KEY", "7eb774f033f0fc5f2c73284d9767058debc98f43dd1110cea80c294313037c99")
lnv_httpClient.SetRequestHeader("Content-Type", "multipart/form-data; boundary=" + ls_BOUNDARY)
li_rc = lnv_httpClient.SendRequest('POST', ls_endpoint, blb_multipart)
// obtain the response data
if li_rc = 1 then
li_ResponseStatusCode = lnv_HttpClient.GetResponseStatusCode()
ls_ResponseStatusMessage = lnv_HttpClient.GetResponseStatusText()
lnv_HttpClient.GetResponseBody(ls_ResponseBody, EncodingUTF8!)
if li_ResponseStatusCode = 200 then
//Okay
end if
end if
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.