Okay all you email fans, we had a customer who wanted to do “unauthenticated email” (like our old / mem map stuff used to do) and apparently the SendEmail command won’t let you do that.
Although, I’d love to hear what “unauthenticated” means to you, since I’ve found a variety of options. We DID add a few options to the SendEmail command(s) in PAC Control, including this one in 9.3e firmware (from the readme): Added the ability to send an email with no user account name from within the strategy.
But that wasn’t going to cut it for a favorite OptoFan who contacted me with another “unauthenticated email” request. However, he was kind enough to donate the code he came up with. It uses the old mem map stuff, but, since it’s part of a strategy, saves some time since all that’s need is self-contained in the strategy. No restart required. He also points out that: “this sends to two separate email addresses, more can be added.”
BTW, before you copy/paste this into your strategy, please make sure you change those “two separate email address” he used for an example, or our IT folks might get upset.
Add in Powerup:
Server_IP = IpAddressStringToInt32("0.0.0.0");// First write the Server IP address
ntMemMapData[0] = Server_IP;
ntMemMapData[1] = bitnot Server_IP; // 1s Complement
Scratch_Pad_Bit_Status = WriteNumTableToIoUnitMemMap(2,0,TestEmail, 0xFFFFF1300000, ntMemMapData );//Server IP
Scratch_Pad_Bit_Status = WriteNumToIoUnitMemMap(TestEmail, 0xFFFFF1300004, 25 ); //Port #
Scratch_Pad_Bit_Status = WriteNumToIoUnitMemMap(TestEmail, 0xFFFFF1200004, MakeInt64(0, 2));
Scratch_Pad_Bit_Status = WriteNumToIoUnitMemMap(TestEmail, 0xFFFFF120001C, 1 );
DelayMsec(1000);
The next snippet goes in its own chart as a single pass after a trigger somewhere else:
Scratch_Pad_Bit_Status = WriteStrToIoUnitMemMap(TestEmail, 0xFFFF130003A, "yourfromemailhere@youremailurlhere.com" ); //Email From
Scratch_Pad_Bit_Status = WriteStrToIoUnitMemMap(TestEmail, 0xFFFF1300008, "mstjohn@opto22.com" ); //Email To
WriteStrToIoUnitMemMap(TestEmail, 0xFFFF130006C, "Oh Happy Day" ); //Email Subject Line
DelayMsec(1000 );
SetIoUnitEventMsgText(TestEmail, 0, Test_Email );
Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 2, 0 );
DelayMsec(1000 );
Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 0, 2 );
nEmail=nEmail+1;
DelayMsec(300 );
Scratch_Pad_Bit_Status = WriteStrToIoUnitMemMap(TestEmail, 0xFFFF1300008, "benorchard@opto22.com" );
DelayMsec(1000 );
SetIoUnitEventMsgText(TestEmail, 0, "Hi Ben" );
Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 2, 0 );
DelayMsec(1000 );
Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 0, 2 );
DelayMsec(1000 );
Thanks for sharing, OptoDan!