Description
The following sample describes how to add a new attachment to a message.
Private Sub cmdTest_Click()
   On Error GoTo ErrorHandler
   Dim vCompany As SAPbobsCOM.Company
  Â
   Set vCompany = New SAPbobsCOM.Company
  Â
   vCompany.CompanyDB = "SBODemo_US"
   vCompany.Password = "manager"
   vCompany.UserName = "manager"
   vCompany.Server = "(local)"
  Â
   If (0 <> vCompany.Connect()) Then
      MsgBox "Failed to connect"
      Exit Sub
   End If
  Â
   Dim msg As SAPbobsCOM.Messages
   Set msg = vCompany.GetBusinessObject(oMessages)
   msg.MessageText = "This is the content of message"
   msg.Subject = "Hello manager"
  Â
   Call msg.Recipients.Add
  Â
   Call msg.Recipients.SetCurentLine(0)
   msg.Recipients.UserCode = "manager"
   msg.Recipients.NameTo = "manager"
   msg.Recipients.SendEmail = tYES
   msg.Recipients.EmailAddress = "manager.Test@hotmail.com"
  Â
   Call msg.Recipients.SetCurentLine(1)
   msg.Recipients.UserCode = "Werner"
   msg.Recipients.NameTo = "Werner"
   msg.Recipients.SendEmail = tYES
   msg.Recipients.EmailAddress = "Werner.Test@hotmail.com"
  Â
   Call msg.AddDataColumn("Please review", "This is an invoice, pls review it, thx.", oInvoices, "1")
  Â
   Call msg.Attachments.Add
   msg.Attachments.Item(0).FileName = "C:\temp\Object.xml"
  Â
   Call msg.Add
   Dim strCode As String
   Call vCompany.GetNewObjectCode(strCode)
   MsgBox ("New Object Code = " + strCode)
  Â
   Dim nErr As Long
   Dim errMsg As String
   Call vCompany.GetLastError(nErr, errMsg)
   If (0 <> nErr) Then
       MsgBox ("Found error:" + errMsg)
   End If
  Â
   Call vCompany.Disconnect
   Set vCompany = Nothing
   Exit Sub
ErrorHandler:
   MsgBox ("Exception:" + Err.Description)
End Sub |