1. OG data type - MessageForSend

    Article: AN0001729Updated: 29.03.2019

    The object is used for definition of email that should be sent to various recipients. You can add files that will sent with the email as attachments.  používá pro definici emailu na různé příjemce. V objektu je možné přidat soubory, které se spolu s emailem odešlou jako přílohy. OG.Send method is used for email sending.

    Object properties

    Name Description
    string Subject Email subject.
    string Body Email body.
    int Priority Email priority.
    bool IsHtml Indication, whether email shall be sent as HTML or PlainText.
    int NotificationId Notification Id.
    Notification Notification Object for notification.
    int EmailTemplateId Email template Id.
    EmailTemplate EmailTemplate Email template object.
    string EmailFrom Sender email.
    string EmailTo List of recipienets TO separated by semicolons.
    string EmailBc List of recipienets BC separated by semicolons.
    string EmailCc List of recipienets CC separated by semicolons.
    EmailAttachmentList Attachements List of email attachments.
    bool SendEmailAsOne Indication, whether email shall be sent to each recipient separately (FALSE), otherwise it will be sent to all the recipients at the same time (TRUE).
    EmailOwnerType OwnerType Type of email owner.
    int? OwnerId Email owner Id.
    DataRow AssignEmailForDataRow Class record, to which the email shall be assigned.
    void AddVariable( string name, object value) Function adds a variable to the email.
    void AddTo(object value) Method adds recipient to TO.
    void AddBc(object value) Method adds recipient to BC.
    void AddCc(object value) Method adds recipient to CC.

    You can define the email by means of properties Subject and Body. The other possibility is to define properties NotificationId or Notification. In such a case email content will be taken over from a notification.

    If you fill in properties EmailTemplateId or EmailTemplate, template will be used. In case there is template defined also in the notification used, it will be ignored and template set in this object will be used.

    When sender email (EmailFrom) is not provided, then email from the web.config file is used.

    Email recipients can be directly defined in properties EmailTo, EmailBc or EmailCc. If you define more recipients, separate them by a semicolon.

    For adding recipients one by one use methods AddTo, AddBc or AddCc. However, you can use as an input also email, Person, PersonList, PersonInfo, PersonInfoList.

    Properties OwnerId a OwnerType are used for linking email and object that generated it. This information is displayed in the list of sent emails in field Owner.

    If the email belongs to a particular class record, fill in also property AssignEmailForDataRow.


    You can add various text variables to the email by means of function AddVariable. They will be inserted into the email before sending.

    You can use the variable in the email in Subject or Body or you can use it directly in the notification. Just state following command of the variable url.




    var m = OG.Email.CreateMessage();

    m.AddTo( dr['solvers']);
    m.AddCc( dr['manager']);

    m.AddVariable('name', OGActualDataRow['name']);
    m.AddVariable('url', OGActualDataRow.DetailUrl);

    var modIT = OG.Model.GetByCode('it');
    m.Notification = OG.Notification.GetAll().GetDefaultByCode( modIT.Id, 'New_RFC');
    m.SendEmailAsOne = true;   //send as a single email