How's it going? I wanted to see if it is possible to attach a file from a WinForms
application in C#
and send it to WhatsApp Desktop. To start the WhatsApp Desktop application I use the following:
var process = $"whatsapp://send?phone={numero}&text={text}";
Process.Start(process);
With that, I get WhatsApp Desktop to open with a default text and a number entered by the user. Now, I would like to know if it is possible to attach a file (image / pdf) to that. I have tried the following:
I create an
OpenDialog
from which I select the file and get its path, I put it in aTextBox
.
Then, to the process I say the following:
string pathFile = txtRuta.Text;
var process = $"whatsapp://send?phone={numero}&text={text}&attachment={pathFile}";
Process.Start(process);
This starts the WhatsApp Desktop but it only shows me the text and the number where it will be sent. Is there any way to attach a file?
CodePudding user response:
(Sorry if this isn't helpful, I'm quite new to Stackoverflow and I'm not a C# expert)
I think that there are two things that could be a possible issue.
You might need to do txtRuta.Text.ToString()
Is the file supposed to be in brackets? (aka {})
CodePudding user response:
From knowledge-wise, it is not viable as it only supports string,
Please use the image URL instead.
Besides, you may also use the website URL. Often Web Scrapper carries images preview of the website to Whatsapp so users will see the snapshot of the website.