A DLL created based on the WeCom webhook for enterprises, making it convenient to directly invoke in programs.
- After pulling the project, use VS2010 or above to open the project
企业微信-Webhook机器人-DLL.sln
. Then modify the value ofurl
by filling in your ownwebhookurl
. Refer to [https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]. - After compiling, generate
workweixinwebhook.dll
for backup.
- Reference
workweixinwebhook.dll
in your project. - Import
workweixinwebhook
. - Define a variable
Dim messageSender As New WeChatMessageSender()
. - Call
messageSender.SendMessage("Enter the content to be called and sent here")
.
Imports workweixinwebhook
Public Class Form1
Dim messageSender As New WeChatMessageSender()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim content As String = DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]")
messageSender.SendMessage(content)
End Sub
Private Sub OnMessageSent(ByVal message As String)
' Logic to handle when the message is successfully sent
MessageBox.Show(message, "Message Sent Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub OnErrorOccurred(ByVal errorMessage As String)
' Logic to handle when there is an error sending the message
MessageBox.Show(errorMessage, "Error Sending Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' Subscribe to events when the form loads
AddHandler messageSender.MessageSent, AddressOf OnMessageSent
AddHandler messageSender.ErrorOccurred, AddressOf OnErrorOccurred
End Sub
Private Sub MainForm_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing
' Unsubscribe from events when the form closes
RemoveHandler messageSender.MessageSent, AddressOf OnMessageSent
RemoveHandler messageSender.ErrorOccurred, AddressOf OnErrorOccurred
End Sub
MIT