📚 SAP Business One SDK Help

Add a Messages object
See Also

Description

The following sample shows how to add a Messages object to the database.
Dim msg As SAPbobsCOM.Messages
Set msg = vCompany.GetBusinessObject(oMessages)
msg.MessageText = "This is the content of message"
msg.Subject = "Hello manager"

'there are two recipients in this message
Call msg.Recipients.Add

'set values for the first recipients
Call msg.Recipients.SetCurentLine(0)
msg.Recipients.UserCode = "manager"
msg.Recipients.NameTo = "manager"
msg.Recipients.SendEmail = tYES
msg.Recipients.EmailAddress = "manager.Test@hotmail.com"

'set values for the second recipient
Call msg.Recipients.SetCurentLine(1)
msg.Recipients.UserCode = "Werner"
msg.Recipients.NameTo = "Werner"
msg.Recipients.SendEmail = tYES
msg.Recipients.EmailAddress = "Werner.Test@hotmail.com"

'set referenced doc
Call msg.AddDataColumn("Please review", "This is an invoice, pls review it, thx.", oInvoices, "1")

'add attachment
Call msg.Attachments.Add
msg.Attachments.Item(0).FileName = "C:\temp\Object.xml"

'send the message
Call msg.Add

Dim strCode As String
Call vCompany.GetNewObjectCode(strCode)
MsgBox ("New Object Code = " + strCode)

'Check Error
Dim nErr As Long
Dim errMsg As String

Call vCompany.GetLastError(nErr, errMsg)
   If (0 <> nErr) Then
       MsgBox ("Found error:" + errMsg)
   End If