Script to send email messages to offline user
Posted: Fri Nov 16, 2018 6:01 pm
This script sends a private message to the user's email if he is offline. To allow the script to send messages, a recipient and sender must fill correct email addresses in their profiles.
The script should be handled to the OnPrivateMessage event on MyChat Server:
Message sending does not impact the server's speed, so you have nothing to worry about.
Instead of sHost, sLogin, sPassword, and sPort you have to type parameters of your email server.
Share your ideas, if any
The script should be handled to the OnPrivateMessage event on MyChat Server:
Message sending does not impact the server's speed, so you have nothing to worry about.
Instead of sHost, sLogin, sPassword, and sPort you have to type parameters of your email server.
Code: Select all
const
sHost = 'mail.yourserver.com';
sLogin = '[email protected]';
sPassword = 'secretpassword';
iPort = 26;
function OnPrivateMessage(iCID, iUIN, iUINTo, iMsgType: integer; sMsg: string): boolean;
var
sEmailTo, sEmailFrom, sTextBody, sNameFrom, sNameTo: string;
begin
result := true;
if not mIsUINOnline(iUINTo) then begin
sEmailTo := mGetUserPrimaryEmail(iUINTo);
sEmailFrom := mGetUserPrimaryEmail(iUIN);
if (length(sEmailTo) > 0) and (length(sEmailFrom) > 0) then begin
sNameFrom := mGetUserFullNameByPreset(iUIN, 0);
sNameTo := mGetUserFullNameByPreset(iUINTo, 0);
sTextBody := '<span style="color:green">' +
FormatDateTime('[mm.dd.yyyy hh:nn:ss]', Now) +
'</span>' +
' '+
'<span style="color:blue"><b>' +
sNameFrom +
'</b></span>'+
'> '+
ReplaceString(mConvertMsgToPlainText(sMsg, iMsgType), CRLF, '</br>', true, false);
SendEmail(sHost, iPort, sLogin, sPassword, sEmailFrom, false, sEmailTo,
'MyChatoffline message for ' + sNameTo, sTextBody, 1, '');
end;
end;
end;
begin
end.
Share your ideas, if any