cancel
Showing results for 
Search instead for 
Did you mean: 

send mail

Former Member
0 Kudos

Hai,

I have created leave approval form. Once the leave status are approved this details should be mailed to HR department. How to send mail ?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member689126
Active Contributor
0 Kudos

Hi

Try this code for sending message

Dim oCmpSrv As SAPbobsCOM.CompanyService
            Dim oMessageService As MessagesService
            Dim oMessage As Message
            Dim oRecipientCollection As RecipientCollection

            'get company service
            oCmpSrv = oCompany.GetCompanyService

            'get msg service
            oMessageService = oCmpSrv.GetBusinessService(ServiceTypes.MessagesService)

            'get the data interface for the new message
            oMessage = oMessageService.GetDataInterface(MessagesServiceDataInterfaces.msdiMessage)

            'fill subject
            oMessage.Subject = "Subject"
  
            'fill text
            oMessage.Text = "Message Body"

            'Add Recipient
            oRecipientCollection = oMessage.RecipientCollection

            'Add new a recipient
            oRecipientCollection.Add()

            'send internal message
            oRecipientCollection.Item(0).UserType = BoMsgRcpTypes.rt_InternalUser
            oRecipientCollection.Item(0).UserCode = "User Code"

            oRecipientCollection.Item(0).SendInternal = BoYesNoEnum.tYES
            oRecipientCollection.Item(0).SendEmail = SAPbobsCOM.BoYesNoEnum.tNO
            oMessage.Priority = SAPbobsCOM.BoMsgPriorities.pr_High

            'send the message
            oMessageService.SendMessage(oMessage)

Hope this helps you

Regards

Arun

Former Member
0 Kudos

hai,

It shows error as

-->'Subject' is not a member of 'System.Windows.Forms.Message'.

--> 'Text' is not a member of 'System.Windows.Forms.Message'.

at 'fill subject

oMessage.Subject = "Subject"

'fill text

oMessage.Text = "Message Body"

Im using VB.Net Windows applications.

how to overcome this.Thanks

former_member689126
Active Contributor
0 Kudos

Hi

Please refer then SDK samples C:\Program Files\SAP\SAP Business One SDK\Samples\COM DI\VB.NET\10.Messages Service

also please post your so that we can check it

Regards

Arun

Former Member
0 Kudos

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If pVal.FormUID = "shift" Then

If pVal.BeforeAction = True Then

Select Case pVal.EventType

Case SAPbouiCOM.BoEventTypes.et_CLICK

Try

Dim oCmpSrv As SAPbobsCOM.CompanyService

Dim oMessageService As SAPbobsCOM.MessagesService

Dim oMessage As Message

Dim oRecipientCollection As SAPbobsCOM.RecipientCollection

'get company service

oCmpSrv = ocompany.GetCompanyService

'get msg service

oMessageService = oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.MessagesService)

'get the data interface for the new message

oMessage = oMessageService.GetDataInterface(SAPbobsCOM.MessagesServiceDataInterfaces.msdiMessage)

'fill subject

oMessage.Subject = "Subject"_-->shows error here_

'fill text

oMessage.text = "Message Body" -->shows error here

'Add Recipient

oRecipientCollection = oMessage.Msg

'Add new a recipient

oRecipientCollection.Add()

'send internal message

oRecipientCollection.Item(0).UserType = SAPbobsCOM.BoMsgRcpTypes.rt_InternalUser

oRecipientCollection.Item(0).UserCode = "User Code"

oRecipientCollection.Item(0).SendInternal = SAPbobsCOM.BoYesNoEnum.tYES

oRecipientCollection.Item(0).SendEmail = SAPbobsCOM.BoYesNoEnum.tNO

oMessage = SAPbobsCOM.BoMsgPriorities.pr_High

'send the message

oMessageService.SendMessage(oMessage)

Catch ex As Exception

End Try

Thanks.

Former Member
0 Kudos

It's this line:

Dim oMessage As Message

That's defining it as a windows API message, you need to specify that it's SAP:

Dim oMessage As SAPbobsCOM.Message

Former Member
0 Kudos

Thanks.

My problem was solved.

One more thing, How can I check the sent mail or received mail. shall u kindly explain.

Thanks once again.

Former Member
0 Kudos

Thanks.

My problem was solved.

One more thing, How can I check the sent mail or received mail. shall u kindly explain.

Thanks once again.

former_member689126
Active Contributor
0 Kudos

Hi

select Windows -


>Messages/Alerts Overview in your SAP Business one main menu .

Regards

Arun

Former Member
0 Kudos

Hai,

Thanks.

I got it.

Answers (0)