Reputation: 1
I am not getting how to send image to any number using WhatsApiNet ?
case "/image":
byte[] imgData = File.ReadAllBytes(@"d:\My Creations\DSC_0423 copy.jpg");
wa.SendMessageImage(tmpUser.GetFullJid(), imgData, ApiBase.ImageType.JPEG);
break;!
But its not working..
Upvotes: 0
Views: 8047
Reputation: 31
I too was facing the same problem, fortunately I got the solution :)
byte[] img = File.ReadAllBytes("e:\\img.gif");
wa.OnConnectSuccess += () =>
{
MessageBox.Show("Connected to whatsapp...");
wa.OnLoginSuccess += (phoneNumber, data) =>
{
wa.SendMessage(to, msg);
wa.SendMessageImage(to + "@s.whatsapp.net",img,ApiBase.ImageType.GIF);
MessageBox.Show("Message Sent...");
};
}
You will just need to modify only 1 line in your code.
wa.SendMessageImage(tmpUser.GetFullJid()+ "@s.whatsapp.net", imgData, ApiBase.ImageType.JPEG);
Hop this will help others too :D Hav a Nyc day :)
Upvotes: 1
Reputation: 6220
See: Is it legal to use WhatsAPI?
There seems to be an indication of ongoing legal issues between WhatsApp and the creator of the API open-source project.
There's also mention that WhatsApp have changed some of the details around authentication, so it may be the case that you can't send the message simply because WhatsApp have stopped allowing access.
Upvotes: 0