Sending an email that you have just received
Hi I'm hoping the community will once more help me out with a question!
Right I have a production that takes an attachment from an email and processes it, sending out a hl7 message at the end. This works ok.
Now I just need to take the email and send it back out to a 'backup' email address, basically giving
a) A backup incase there is a problem with the email or something else further down the line.
b) A log of the emails receieved.
So I thought the best thing to do is have an operation with an email adapter and to send that my message.
That gave me some code that's basically like this.
{
Parameter ADAPTER = "eReferral.eRefInboundAdapter";
Method OnProcessInput(pInput As %Net.MailMessage, pOutput As %RegisteredObject) As %Status
{
do ..SendRequestSync("sendBackup",newMessage,.pResp)
$$$TRACE($ZCVT($ZERROR,"O","HTML"))
//more things to process the attatchment
}
}
Then I have the sendBackup service as
Class eReferral.SendBackupEmail Extends Ens.BusinessOperation
{
Parameter ADAPTER = "EnsLib.EMail.OutboundAdapter";
Property Adapter As EnsLib.EMail.OutboundAdapter;
Parameter INVOCATION = "Queue";
Method SendEmail(pInput As %Net.MailMessage, Output pOutput As Ens.Response) As %Status
{
do pInput.To.Clear()
do pInput.To.Insert(..Adapter.Recipient)
set pInput.From = ..Adapter.SMTP.authenticator.UserName
Set tSc=..Adapter.SendMail(email)
Quit tSc
}
XData MessageMap
{
<MapItems>
<MapItem MessageType="%Net.MailMessage">
<Method>SendEmail</Method>
</MapItem>
</MapItems>
}
}
But I get
ERROR #5002: Cache error: <SUBSCRIPT>%SaveData+23^Ens.MessageHeader.1 ^Ens.MessageHeaderI("MessageBodyId","UTF-8
On the EmailAdapter object when I make that call do the "sendBackup" object.
What am I doing wrong - how can I debug this?
Thanks
Regards
Richard