on 09-24-2008 5:22 PM
Good Day
Experts:
I am looking to Send a message with an attachment from my AddOn code to a recipient.
For now, I am just trying to send it to myself here internally. I have spent time in the Help, Sample and the forum
with no luck. The Messages object and the Messages Services and I cannot get the code to send an e-mail.
Now, my SBO Mailer service is started in the SAP B1 Serve Suite Manager.
Here is my code for the oMessages object. This adds without error but I never get the e-mail. Is there somewhere I can check to see if the email got lost?
Dim lErrCode As Long
Dim sErrMsg As String
lErrCode = Nothing
sErrMsg = ""
Dim msg As SAPbobsCOM.Messages
msg = g_B1Connection.Company.GetBusinessObject(BoObjectTypes.oMessages)
msg.MessageText = "This is the content of message"
msg.Subject = "Hello manager"
Call msg.Recipients.Add()
msg.Recipients.UserCode = "manager"
msg.Recipients.NameTo = "manager"
msg.Recipients.SendEmail = BoYesNoEnum.tYES
msg.Recipients.EmailAddress = "<email address>"
Call msg.Attachments.Add()
msg.Attachments.Item(0).FileName = "C:\NextBPCode.txt"
msg.Add()
g_B1Connection.Company.GetLastError(lErrCode, sErrMsg)
If lErrCode = 0 Then
Else
UpdateStatus("Error sending email..." & sErrMsg & "", SAPbouiCOM.BoStatusBarMessageType.smt_Error)
End If
Any help is appreciated as I have spent way too much time so far on this issue.
Thanks,
EJD
Hi Ed,
Your code works fine (I can send emails to an account with attachments using this code).
I'm assuming that you can send the message (and attachment) if you do it manually through the user-interface. If you don't get the message when you do it manually then check your SBO Mailer settings.
When you add a message in SBO you should see new entries in the OALR and ALR1 tables. The ALR1 table has a status column (U for unsent, P for pending, S for sent and E for error). If the status remains at U then your mailer is not attempting to send the email. If you get an E status then check the application log in Event Viewer as this should record a more detailed error message (and then check SAP Notes for the code). Also check your attachments path to see if the attachment has been copied across (attachment path is in the path tab of General Settings).
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.