Skip to Content
author's profile photo Former Member
Former Member

Send mail

 Private Sub SendMessage(ByVal strSubject As String, ByVal Msg As String)
        Dim objMsg As SAPbobsCOM.Messages
        Dim lngStatus As Long

        Try

            objMsg = objCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oMessages)
            objMsg.Subject = strSubject
            objMsg.MessageText = Msg

            objMsg.Recipients.Add()
            objMsg.Recipients.SetCurrentLine(0)
            objMsg.Recipients.UserCode = "manager"
            objMsg.Recipients.EmailAddress = valid email address
            objMsg.Recipients.SendInternal = SAPbobsCOM.BoYesNoEnum.tNO
            objMsg.Recipients.SendEmail = SAPbobsCOM.BoYesNoEnum.tYES
            objMsg.Priority = SAPbobsCOM.BoMsgPriorities.pr_High

            lngStatus = objMsg.Add
            If objCompany.GetLastErrorDescription.Length > 0 Then
                SBO_Application.MessageBox(objCompany.GetLastErrorDescription)
            End If
        Catch ex As Exception
            SBO_Application.MessageBox(ex.Message)
        End Try
    End Sub

I want to send emai through DI API.I have used the above code.

It is not giving any error but I am not receiving email.I want to receive

email and not an message that pop ups in SAP.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Dec 29, 2008 at 09:30 AM

    Dilip,

    Can you send the email with Alert Management in B1? Have you finished the customization of Mailer Service in Server Tool. Please refer the relevant installaiton guide for help. Thanks.

    Regards, Yatsea

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2009 at 12:05 PM

    I used the following function for sending mail-

    Private Function GenEmail(ByVal strSubject As String, ByVal strMsg As String, ByVal strType As String) As Boolean
            Dim objOutlookApp As New Outlook.Application
            Dim intI As Integer
            Dim objMail As Outlook._MailItem
            Dim strEmailID As String
            Dim lngStatus As Long
            Dim objDT As New DataTable
    
            Try
                objMail = objOutlookApp.CreateItem(Outlook.OlItemType.olMailItem)
                objMail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
                objMail.Subject = strSubject
    
                strMsg = "<font face='Trebuchet MS,Arial, Helvetica, sans-serif' size='2'> Sir/Madam,<br><br>" & strMsg & "<br><br>Regards,<br>SAP TEAM.<br><br>"
                strMsg = strMsg & "<b>Note:Please do not reply.This is auto generated mail.<b></font>"
                objMail.HTMLBody = strMsg
                strQuery = "Select * from [@U_MCNA] Where U_Alert_Type='" & strType & "'"
                objDT = GetData(strQuery)
                strEmailID = ""
                If objDT.Rows.Count > 0 Then
                    For intI = 0 To objDT.Rows.Count - 1
                        If strEmailID.Length = 0 Then
                            strEmailID = objDT.Rows(intI).Item("U_Email_Id")
                        Else
                            strEmailID = strEmailID & ";" & objDT.Rows(intI).Item("U_Email_Id")
                        End If
                    Next
                    objMail.To = strEmailID
                    objMail.ReadReceiptRequested = True
                    objMail.Send()
                    objMail = Nothing
                Else
                    SBO_Application.MessageBox("No Message Recipients defined")
                    DeletePCHN()
                End If
    
            Catch ex As Exception
                SBO_Application.MessageBox("GenEmail()=" & ex.Message)
            Finally
                objOutlookApp = Nothing
                objMail = Nothing
                objDT = Nothing
            End Try
        End Function
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.