(function (module, require) {
'use strict';
var
window = require('window'),
_ = require('_'),
$ = require('$'),
ko = require('ko'),
moment = require('moment'),
JSON = require('JSON'),
Jua = require('Jua'),
Enums = require('Enums'),
Consts = require('Consts'),
Utils = require('Utils'),
Globals = require('Globals'),
Events = require('Events'),
LinkBuilder = require('LinkBuilder'),
HtmlEditor = require('HtmlEditor'),
Settings = require('Storage:Settings'),
Data = require('Storage:RainLoop:Data'),
Cache = require('Storage:RainLoop:Cache'),
Remote = require('Storage:RainLoop:Remote'),
ComposeAttachmentModel = require('Model:ComposeAttachment'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsComposeViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsCompose');
this.oEditor = null;
this.aDraftInfo = null;
this.sInReplyTo = '';
this.bFromDraft = false;
this.bSkipNext = false;
this.sReferences = '';
this.bCapaAdditionalIdentities = Settings.capa(Enums.Capa.AdditionalIdentities);
var
self = this,
fCcAndBccCheckHelper = function (aValue) {
if (false === self.showCcAndBcc() && 0 < aValue.length)
{
self.showCcAndBcc(true);
}
}
;
this.capaOpenPGP = Data.capaOpenPGP;
this.resizer = ko.observable(false).extend({'throttle': 50});
this.identitiesDropdownTrigger = ko.observable(false);
this.to = ko.observable('');
this.to.focusTrigger = ko.observable(false);
this.cc = ko.observable('');
this.bcc = ko.observable('');
this.replyTo = ko.observable('');
this.subject = ko.observable('');
this.isHtml = ko.observable(false);
this.requestReadReceipt = ko.observable(false);
this.sendError = ko.observable(false);
this.sendSuccessButSaveError = ko.observable(false);
this.savedError = ko.observable(false);
this.savedTime = ko.observable(0);
this.savedOrSendingText = ko.observable('');
this.emptyToError = ko.observable(false);
this.attachmentsInProcessError = ko.observable(false);
this.showCcAndBcc = ko.observable(false);
this.cc.subscribe(fCcAndBccCheckHelper, this);
this.bcc.subscribe(fCcAndBccCheckHelper, this);
this.draftFolder = ko.observable('');
this.draftUid = ko.observable('');
this.sending = ko.observable(false);
this.saving = ko.observable(false);
this.attachments = ko.observableArray([]);
this.attachmentsInProcess = this.attachments.filter(function (oItem) {
return oItem && '' === oItem.tempName();
});
this.attachmentsInReady = this.attachments.filter(function (oItem) {
return oItem && '' !== oItem.tempName();
});
this.attachments.subscribe(function () {
this.triggerForResize();
}, this);
this.isDraftFolderMessage = ko.computed(function () {
return '' !== this.draftFolder() && '' !== this.draftUid();
}, this);
this.composeUploaderButton = ko.observable(null);
this.composeUploaderDropPlace = ko.observable(null);
this.dragAndDropEnabled = ko.observable(false);
this.dragAndDropOver = ko.observable(false).extend({'throttle': 1});
this.dragAndDropVisible = ko.observable(false).extend({'throttle': 1});
this.attacheMultipleAllowed = ko.observable(false);
this.addAttachmentEnabled = ko.observable(false);
this.composeEditorArea = ko.observable(null);
this.identities = Data.identities;
this.defaultIdentityID = Data.defaultIdentityID;
this.currentIdentityID = ko.observable('');
this.currentIdentityString = ko.observable('');
this.currentIdentityResultEmail = ko.observable('');
this.identitiesOptions = ko.computed(function () {
var aList = [{
'optValue': Data.accountEmail(),
'optText': this.formattedFrom(false)
}];
_.each(Data.identities(), function (oItem) {
aList.push({
'optValue': oItem.id,
'optText': oItem.formattedNameForCompose()
});
});
return aList;
}, this);
ko.computed(function () {
var
sResult = '',
sResultEmail = '',
oItem = null,
aList = this.identities(),
sID = this.currentIdentityID()
;
if (this.bCapaAdditionalIdentities && sID && sID !== Data.accountEmail())
{
oItem = _.find(aList, function (oItem) {
return oItem && sID === oItem['id'];
});
sResult = oItem ? oItem.formattedNameForCompose() : '';
sResultEmail = oItem ? oItem.formattedNameForEmail() : '';
if ('' === sResult && aList[0])
{
this.currentIdentityID(aList[0]['id']);
return '';
}
}
if ('' === sResult)
{
sResult = this.formattedFrom(false);
sResultEmail = this.formattedFrom(true);
}
this.currentIdentityString(sResult);
this.currentIdentityResultEmail(sResultEmail);
return sResult;
}, this);
this.to.subscribe(function (sValue) {
if (this.emptyToError() && 0 < sValue.length)
{
this.emptyToError(false);
}
}, this);
this.attachmentsInProcess.subscribe(function (aValue) {
if (this.attachmentsInProcessError() && Utils.isArray(aValue) && 0 === aValue.length)
{
this.attachmentsInProcessError(false);
}
}, this);
this.editorResizeThrottle = _.throttle(_.bind(this.editorResize, this), 100);
this.resizer.subscribe(function () {
this.editorResizeThrottle();
}, this);
this.canBeSendedOrSaved = ko.computed(function () {
return !this.sending() && !this.saving();
}, this);
this.deleteCommand = Utils.createCommand(this, function () {
require('App:RainLoop').deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]);
kn.hideScreenPopup(PopupsComposeViewModel);
}, function () {
return this.isDraftFolderMessage();
});
this.sendMessageResponse = _.bind(this.sendMessageResponse, this);
this.saveMessageResponse = _.bind(this.saveMessageResponse, this);
this.sendCommand = Utils.createCommand(this, function () {
var
sTo = Utils.trim(this.to()),
sSentFolder = Data.sentFolder(),
aFlagsCache = []
;
if (0 < this.attachmentsInProcess().length)
{
this.attachmentsInProcessError(true);
}
else if (0 === sTo.length)
{
this.emptyToError(true);
}
else
{
if (Data.replySameFolder())
{
if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && Utils.isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length)
{
sSentFolder = this.aDraftInfo[2];
}
}
if ('' === sSentFolder)
{
kn.showScreenPopup(require('View:Popup:FolderSystem'), [Enums.SetSystemFoldersNotification.Sent]);
}
else
{
this.sendError(false);
this.sending(true);
if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length)
{
aFlagsCache = Cache.getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]);
if (aFlagsCache)
{
if ('forward' === this.aDraftInfo[0])
{
aFlagsCache[3] = true;
}
else
{
aFlagsCache[2] = true;
}
Cache.setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache);
require('App:RainLoop').reloadFlagsCurrentMessageListAndMessageFromCache();
Cache.setFolderHash(this.aDraftInfo[2], '');
}
}
sSentFolder = Consts.Values.UnuseOptionValue === sSentFolder ? '' : sSentFolder;
Cache.setFolderHash(this.draftFolder(), '');
Cache.setFolderHash(sSentFolder, '');
Remote.sendMessage(
this.sendMessageResponse,
this.draftFolder(),
this.draftUid(),
sSentFolder,
this.currentIdentityResultEmail(),
sTo,
this.cc(),
this.bcc(),
this.subject(),
this.oEditor ? this.oEditor.isHtml() : false,
this.oEditor ? this.oEditor.getData(true) : '',
this.prepearAttachmentsForSendOrSave(),
this.aDraftInfo,
this.sInReplyTo,
this.sReferences,
this.requestReadReceipt()
);
}
}
}, this.canBeSendedOrSaved);
this.saveCommand = Utils.createCommand(this, function () {
if (Data.draftFolderNotEnabled())
{
kn.showScreenPopup(require('View:Popup:FolderSystem'), [Enums.SetSystemFoldersNotification.Draft]);
}
else
{
this.savedError(false);
this.saving(true);
this.bSkipNext = true;
Cache.setFolderHash(Data.draftFolder(), '');
Remote.saveMessage(
this.saveMessageResponse,
this.draftFolder(),
this.draftUid(),
Data.draftFolder(),
this.currentIdentityResultEmail(),
this.to(),
this.cc(),
this.bcc(),
this.subject(),
this.oEditor ? this.oEditor.isHtml() : false,
this.oEditor ? this.oEditor.getData(true) : '',
this.prepearAttachmentsForSendOrSave(),
this.aDraftInfo,
this.sInReplyTo,
this.sReferences
);
}
}, this.canBeSendedOrSaved);
Events.sub('interval.1m', function () {
if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
!this.bSkipNext && !this.saving() && !this.sending() && !this.savedError())
{
this.bSkipNext = false;
this.saveCommand();
}
}, this);
this.showCcAndBcc.subscribe(function () {
this.triggerForResize();
}, this);
this.dropboxEnabled = ko.observable(!!Settings.settingsGet('DropboxApiKey'));
this.dropboxCommand = Utils.createCommand(this, function () {
if (window.Dropbox)
{
window.Dropbox.choose({
//'iframe': true,
'success': function(aFiles) {
if (aFiles && aFiles[0] && aFiles[0]['link'])
{
self.addDropboxAttachment(aFiles[0]);
}
},
'linkType': "direct",
'multiselect': false
});
}
return true;
}, function () {
return this.dropboxEnabled();
});
this.driveEnabled = ko.observable(Globals.bXMLHttpRequestSupported &&
!!Settings.settingsGet('GoogleClientID') && !!Settings.settingsGet('GoogleApiKey'));
this.driveVisible = ko.observable(false);
this.driveCommand = Utils.createCommand(this, function () {
this.driveOpenPopup();
return true;
}, function () {
return this.driveEnabled();
});
this.driveCallback = _.bind(this.driveCallback, this);
this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.Compose;
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
this.emailsSource = _.bind(this.emailsSource, this);
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View:Popup:Compose', 'PopupsComposeViewModel'], PopupsComposeViewModel);
_.extend(PopupsComposeViewModel.prototype, KnoinAbstractViewModel.prototype);
PopupsComposeViewModel.prototype.emailsSource = function (oData, fResponse)
{
require('App:RainLoop').getAutocomplete(oData.term, function (aData) {
fResponse(_.map(aData, function (oEmailItem) {
return oEmailItem.toLine(false);
}));
});
};
PopupsComposeViewModel.prototype.openOpenPgpPopup = function ()
{
if (this.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml())
{
var self = this;
kn.showScreenPopup(require('View:Popup:ComposeOpenPgp'), [
function (sResult) {
self.editor(function (oEditor) {
oEditor.setPlain(sResult);
});
},
this.oEditor.getData(),
this.currentIdentityResultEmail(),
this.to(),
this.cc(),
this.bcc()
]);
}
};
PopupsComposeViewModel.prototype.reloadDraftFolder = function ()
{
var
sDraftFolder = Data.draftFolder()
;
if ('' !== sDraftFolder)
{
Cache.setFolderHash(sDraftFolder, '');
if (Data.currentFolderFullNameRaw() === sDraftFolder)
{
require('App:RainLoop').reloadMessageList(true);
}
else
{
require('App:RainLoop').folderInformation(sDraftFolder);
}
}
};
PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeType, oMessage)
{
var
oIDs = {},
sResult = '',
fFindHelper = function (oItem) {
if (oItem && oItem.email && oIDs[oItem.email])
{
sResult = oIDs[oItem.email];
return true;
}
return false;
}
;
if (this.bCapaAdditionalIdentities)
{
_.each(this.identities(), function (oItem) {
oIDs[oItem.email()] = oItem['id'];
});
}
oIDs[Data.accountEmail()] = Data.accountEmail();
if (oMessage)
{
switch (sComposeType)
{
case Enums.ComposeType.Empty:
break;
case Enums.ComposeType.Reply:
case Enums.ComposeType.ReplyAll:
case Enums.ComposeType.Forward:
case Enums.ComposeType.ForwardAsAttachment:
_.find(_.union(oMessage.to, oMessage.cc, oMessage.bcc, oMessage.deliveredTo), fFindHelper);
break;
case Enums.ComposeType.Draft:
_.find(_.union(oMessage.from, oMessage.replyTo), fFindHelper);
break;
}
}
if ('' === sResult)
{
sResult = this.defaultIdentityID();
}
if ('' === sResult)
{
sResult = Data.accountEmail();
}
return sResult;
};
PopupsComposeViewModel.prototype.selectIdentity = function (oIdentity)
{
if (oIdentity)
{
this.currentIdentityID(oIdentity.optValue);
}
};
/**
*
* @param {boolean=} bHeaderResult = false
* @returns {string}
*/
PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
{
var
sDisplayName = Data.displayName(),
sEmail = Data.accountEmail()
;
return '' === sDisplayName ? sEmail :
((Utils.isUnd(bHeaderResult) ? false : !!bHeaderResult) ?
'"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>' :
sDisplayName + ' (' + sEmail + ')')
;
};
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
{
var
bResult = false,
sMessage = ''
;
this.sending(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
bResult = true;
if (this.modalVisibility())
{
Utils.delegateRun(this, 'closeCommand');
}
}
if (this.modalVisibility() && !bResult)
{
if (oData && Enums.Notification.CantSaveMessage === oData.ErrorCode)
{
this.sendSuccessButSaveError(true);
window.alert(Utils.trim(Utils.i18n('COMPOSE/SAVED_ERROR_ON_SEND')));
}
else
{
sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage,
oData && oData.ErrorMessage ? oData.ErrorMessage : '');
this.sendError(true);
window.alert(sMessage || Utils.getNotification(Enums.Notification.CantSendMessage));
}
}
this.reloadDraftFolder();
};
PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
{
var
bResult = false,
oMessage = null
;
this.saving(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
if (oData.Result.NewFolder && oData.Result.NewUid)
{
if (this.bFromDraft)
{
oMessage = Data.message();
if (oMessage && this.draftFolder() === oMessage.folderFullNameRaw && this.draftUid() === oMessage.uid)
{
Data.message(null);
}
}
this.draftFolder(oData.Result.NewFolder);
this.draftUid(oData.Result.NewUid);
if (this.modalVisibility())
{
this.savedTime(window.Math.round((new window.Date()).getTime() / 1000));
this.savedOrSendingText(
0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', {
'TIME': moment.unix(this.savedTime() - 1).format('LT')
}) : ''
);
bResult = true;
if (this.bFromDraft)
{
Cache.setFolderHash(this.draftFolder(), '');
}
}
}
}
if (!this.modalVisibility() && !bResult)
{
this.savedError(true);
this.savedOrSendingText(Utils.getNotification(Enums.Notification.CantSaveMessage));
}
this.reloadDraftFolder();
};
PopupsComposeViewModel.prototype.onHide = function ()
{
this.reset();
kn.routeOn();
};
/**
* @param {string} sSignature
* @param {string=} sFrom
* @param {string=} sData
* @param {string=} sComposeType
* @return {string}
*/
PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType)
{
var bHtml = false, bData = false;
if ('' !== sSignature)
{
if (':HTML:' === sSignature.substr(0, 6))
{
bHtml = true;
sSignature = sSignature.substr(6);
}
sSignature = sSignature.replace(/[\r]/g, '');
sFrom = Utils.pString(sFrom);
if ('' !== sFrom)
{
sSignature = sSignature.replace(/{{FROM}}/g, sFrom);
}
sSignature = sSignature.replace(/[\s]{1,2}{{FROM}}/g, '{{FROM}}');
sSignature = sSignature.replace(/{{FROM}}/g, '');
sSignature = sSignature.replace(/{{DATE}}/g, moment().format('llll'));
if (sData && Enums.ComposeType.Empty === sComposeType &&
-1 < sSignature.indexOf('{{DATA}}'))
{
bData = true;
sSignature = sSignature.replace('{{DATA}}', sData);
}
sSignature = sSignature.replace(/{{DATA}}/g, '');
if (!bHtml)
{
sSignature = Utils.convertPlainTextToHtml(sSignature);
}
}
if (sData && !bData)
{
switch (sComposeType)
{
case Enums.ComposeType.Empty:
sSignature = sData + '
' + sSignature;
break;
default:
sSignature = sSignature + '
' + sData;
break;
}
}
return sSignature;
};
PopupsComposeViewModel.prototype.editor = function (fOnInit)
{
if (fOnInit)
{
var self = this;
if (!this.oEditor && this.composeEditorArea())
{
_.delay(function () {
self.oEditor = new HtmlEditor(self.composeEditorArea(), null, function () {
fOnInit(self.oEditor);
}, function (bHtml) {
self.isHtml(!!bHtml);
});
}, 300);
}
else if (this.oEditor)
{
fOnInit(this.oEditor);
}
}
};
/**
* @param {string=} sType = Enums.ComposeType.Empty
* @param {?MessageModel|Array=} oMessageOrArray = null
* @param {Array=} aToEmails = null
* @param {string=} sCustomSubject = null
* @param {string=} sCustomPlainText = null
*/
PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText)
{
kn.routeOff();
var
self = this,
sFrom = '',
sTo = '',
sCc = '',
sDate = '',
sSubject = '',
oText = null,
sText = '',
sReplyTitle = '',
aResplyAllParts = [],
oExcludeEmail = {},
mEmail = Data.accountEmail(),
sSignature = Data.signature(),
bSignatureToAll = Data.signatureToAll(),
aDownloads = [],
aDraftInfo = null,
oMessage = null,
sComposeType = sType || Enums.ComposeType.Empty,
fEmailArrayToStringLineHelper = function (aList, bFriendly) {
var
iIndex = 0,
iLen = aList.length,
aResult = []
;
for (; iIndex < iLen; iIndex++)
{
aResult.push(aList[iIndex].toLine(!!bFriendly));
}
return aResult.join(', ');
}
;
oMessageOrArray = oMessageOrArray || null;
if (oMessageOrArray && Utils.isNormal(oMessageOrArray))
{
oMessage = Utils.isArray(oMessageOrArray) && 1 === oMessageOrArray.length ? oMessageOrArray[0] :
(!Utils.isArray(oMessageOrArray) ? oMessageOrArray : null);
}
if (null !== mEmail)
{
oExcludeEmail[mEmail] = true;
}
this.currentIdentityID(this.findIdentityIdByMessage(sComposeType, oMessage));
this.reset();
if (Utils.isNonEmptyArray(aToEmails))
{
this.to(fEmailArrayToStringLineHelper(aToEmails));
}
if ('' !== sComposeType && oMessage)
{
sDate = oMessage.fullFormatDateValue();
sSubject = oMessage.subject();
aDraftInfo = oMessage.aDraftInfo;
oText = $(oMessage.body).clone();
if (oText)
{
oText.find('blockquote.rl-bq-switcher').each(function () {
$(this).removeClass('rl-bq-switcher hidden-bq');
});
oText.find('.rlBlockquoteSwitcher').each(function () {
$(this).remove();
});
}
oText.find('[data-html-editor-font-wrapper]').removeAttr('data-html-editor-font-wrapper');
sText = oText.html();
switch (sComposeType)
{
case Enums.ComposeType.Empty:
break;
case Enums.ComposeType.Reply:
this.to(fEmailArrayToStringLineHelper(oMessage.replyEmails(oExcludeEmail)));
this.subject(Utils.replySubjectAdd('Re', sSubject));
this.prepearMessageAttachments(oMessage, sComposeType);
this.aDraftInfo = ['reply', oMessage.uid, oMessage.folderFullNameRaw];
this.sInReplyTo = oMessage.sMessageId;
this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences);
break;
case Enums.ComposeType.ReplyAll:
aResplyAllParts = oMessage.replyAllEmails(oExcludeEmail);
this.to(fEmailArrayToStringLineHelper(aResplyAllParts[0]));
this.cc(fEmailArrayToStringLineHelper(aResplyAllParts[1]));
this.subject(Utils.replySubjectAdd('Re', sSubject));
this.prepearMessageAttachments(oMessage, sComposeType);
this.aDraftInfo = ['reply', oMessage.uid, oMessage.folderFullNameRaw];
this.sInReplyTo = oMessage.sMessageId;
this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.references());
break;
case Enums.ComposeType.Forward:
this.subject(Utils.replySubjectAdd('Fwd', sSubject));
this.prepearMessageAttachments(oMessage, sComposeType);
this.aDraftInfo = ['forward', oMessage.uid, oMessage.folderFullNameRaw];
this.sInReplyTo = oMessage.sMessageId;
this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences);
break;
case Enums.ComposeType.ForwardAsAttachment:
this.subject(Utils.replySubjectAdd('Fwd', sSubject));
this.prepearMessageAttachments(oMessage, sComposeType);
this.aDraftInfo = ['forward', oMessage.uid, oMessage.folderFullNameRaw];
this.sInReplyTo = oMessage.sMessageId;
this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences);
break;
case Enums.ComposeType.Draft:
this.to(fEmailArrayToStringLineHelper(oMessage.to));
this.cc(fEmailArrayToStringLineHelper(oMessage.cc));
this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc));
this.bFromDraft = true;
this.draftFolder(oMessage.folderFullNameRaw);
this.draftUid(oMessage.uid);
this.subject(sSubject);
this.prepearMessageAttachments(oMessage, sComposeType);
this.aDraftInfo = Utils.isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null;
this.sInReplyTo = oMessage.sInReplyTo;
this.sReferences = oMessage.sReferences;
break;
case Enums.ComposeType.EditAsNew:
this.to(fEmailArrayToStringLineHelper(oMessage.to));
this.cc(fEmailArrayToStringLineHelper(oMessage.cc));
this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc));
this.subject(sSubject);
this.prepearMessageAttachments(oMessage, sComposeType);
this.aDraftInfo = Utils.isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null;
this.sInReplyTo = oMessage.sInReplyTo;
this.sReferences = oMessage.sReferences;
break;
}
switch (sComposeType)
{
case Enums.ComposeType.Reply:
case Enums.ComposeType.ReplyAll:
sFrom = oMessage.fromToLine(false, true);
sReplyTitle = Utils.i18n('COMPOSE/REPLY_MESSAGE_TITLE', {
'DATETIME': sDate,
'EMAIL': sFrom
});
sText = '
' + sReplyTitle + ':' +
'
'; break; case Enums.ComposeType.Forward: sFrom = oMessage.fromToLine(false, true); sTo = oMessage.toToLine(false, true); sCc = oMessage.ccToLine(false, true); sText = '' + sText + '