Hi
I am auto attatching a purchase order to an email (pdf) and then attaching a separate pdf for the terms and conditions. 90% of the time this works great but every so often it fails to attach the terms and conditions (the second attachment) for certain users. Sometimes the functionality comes back and sometimes not.
The first attachment always succeeds no matter what. I am using a custom function of codeunit 397 in Navision v5.
Attachfilename is the purchase order, the second attachment is a custom field in the purchase setup. All code executes as it should, no errors even when unsuccessful. I have cleared zup files, reset exchange profiles. When it goes it is user specific but everything checks out for that user (permissions to filels etc).
Thanks for any help, it is frustrating the life out of me.
IF ISCLEAR(BSTRConverterAttachFileName) THEN
CREATE(BSTRConverterAttachFileName);
IF AttachFileName <> '' THEN BEGIN
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName);
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(PurchSetupLcl."Purch. Terms Path");
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
END;
Comments
1 is variable (The purchase order) and this always works. The 2nd is a fixed named file. Mostly it works but when it fails there is no reason that I can see as to why. I have managed to get it going again for some users where it has failed but I don't know how I did this, it just began to work again.
There is no AV trigger or user block, the environment doesn't change.
Thanks
I modified codeunit 397 to add a terms and conditions document. There are conditions, depending on companyname and type of transaction, so I save the name of the terms and conditions document to a variable AttachFileName2.
Then I have exactly what you have, except for the variable name instead of the file name text.
The terms and conditions documents are on a shared network drive that everyone is mapped to.
As far as I know, it works.
Why not try saving your terms and conditions file name to a variable, and use that like:
BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName2);
Just a thought.
I think I will and see how it goes. I have fixed all the problem users but only by a laborious rebuild of their roaming profile but still no errors. I'll try it and post if it fails again.
Thanks again