From sgcWebSockets 2022.7.0, now you can upload local files (like pdf, videos, audios...) to WhatsApp Servers and send a message to your users. Previously to this improvement, you can only send files to users that were uploaded previously to a public website.
Image Messages
Call the method SendMessageImage and pass the following parameters:
- aTo: phone number
- aFileName: full filename (with path) of the image file to send.
- aFileType:
- image/jpeg
- image/png
- aCaption: title of the image (optional).
oClient := TsgcWhatsApp_Client.Create(nil); oClient.WhatsappOptions.PhoneNumberId := '107809351952205'; oClient.WhatsappOptions.Token := 'EAAO4OpgZAs98BAGj3nCFGr...ZB2t8mmLB2LRXJkte2Y5PMNh2'; oClient.SendFileImage('34605889421', 'c:\images\image.png', 'image/png');
Document Messages
Call the method SendMessageDocument and pass the following parameters:
- aTo: phone number
- aFileName: full filename (with path) of the document file to send.
- aFileType:
- text/plain
- application/pdf
- application/vnd.ms-powerpoint
- application/msword
- application/vnd.ms-excel
- application/vnd.openxmlformats-officedocument.wordprocessingml.document
- application/vnd.openxmlformats-officedocument.presentationml.presentation
- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
- aCaption: title of the document (optional).
oClient := TsgcWhatsApp_Client.Create(nil); oClient.WhatsappOptions.PhoneNumberId := '107809351952205'; oClient.WhatsappOptions.Token := 'EAAO4OpgZAs98BAGj3nCFGr...ZB2t8mmLB2LRXJkte2Y5PMNh2'; oClient.SendFileDocument('34605889421', 'c:\MyDocuments\invoice.pdf', 'application/pdf');
Audio Messages
Call the method SendMessageAudio and pass the following parameters:
- aTo: phone number
- aFileName: full filename (with path) of the audio file to send.
- aFileType:
- audio/aac
- audio/mp4
- audio/mpeg
- audio/amr
- audio/ogg
oClient := TsgcWhatsApp_Client.Create(nil); oClient.WhatsappOptions.PhoneNumberId := '107809351952205'; oClient.WhatsappOptions.Token := 'EAAO4OpgZAs98BAGj3nCFGr...ZB2t8mmLB2LRXJkte2Y5PMNh2'; oClient.SendFileAudio('34605889421', 'c:\Music\audio.mp3', 'audio/mp4');
Video Messages
Call the method SendMessageVideo and pass the following parameters:
- aTo: phone number
- aFileName: full filename (with path) of the video file to send.
- aFileType:
- video/mp4
- video/3gp
oClient := TsgcWhatsApp_Client.Create(nil); oClient.WhatsappOptions.PhoneNumberId := '107809351952205'; oClient.WhatsappOptions.Token := 'EAAO4OpgZAs98BAGj3nCFGr...ZB2t8mmLB2LRXJkte2Y5PMNh2'; oClient.SendFileVideo('34605889421', 'c:\Videos\video.mp4', 'video/mp4');
Sticker Messages
Call the method SendMessageSticker and pass the following parameters:
- aTo: phone number
- aFileName: full filename (with path) of the sticker file to send.
- aFileType:
- image/webp
oClient := TsgcWhatsApp_Client.Create(nil); oClient.WhatsappOptions.PhoneNumberId := '107809351952205'; oClient.WhatsappOptions.Token := 'EAAO4OpgZAs98BAGj3nCFGr...ZB2t8mmLB2LRXJkte2Y5PMNh2'; oClient.SendFileSticker('34605889421', 'c:\Stickers\MySicker.webp', 'image/webp');