Send Mail in OpenERP with Mail Templates

Hello

    Now a days Mailing mechanism is to fast for any communication. Here I would like to serve you how to send mail in openerp and how to use a custom templates for sending mail.

Required module for Installation:

--> email_templates
    Here First of all you need to configure outgoing email server.
    For Outing Mail Servers:
        Settings/Technical/Email/Outing Mail Servers











Google:
    smtp.gmail.com
    SSL Port 465
    StartTLS Port 587

Yahoo:
    smtp.mail.yahoo.com
    SSL Port 465



If you success to configure openerp outgoing email server then lets see how to use a custom templates for sending mail.

Here First of all you need to install email_template module.This module is used to specify the format in which the email has to be send.


For Templates:
      Settings/Technical/Email/Templates





















In templates need to set required field

Name : Name of the template
Applies to: Model to which the template is related [Ex: sale order]
Form: sender address
To: Destination mail address
Reply To : Preferred Reply address
Subject : Subject of the mail
Body : Body of the email [either plain text or an HTML format]
Add signature: predefine signature for all.


Main important feature of email_templates is dynamically value builder tab where you can fetch your required field from related document model and also use the field value in [Form,TO,Subject,Body] anywhere in mail template.

















Field Description:

Field : Select field from Applies to model
    In our Example:we select sale order modele in applies to so all sale order filed display here like [name, ref, company_id, partner_id, etc]

Sub-Model : When a relation field like many2one is selected, this field specify the Related model.
       Example: partner_id is many2one field which related with res.partner
   
Sub-field : When a relation field is selected, this field let us select the target field inside the Sub-Model
        Ex: In sub-model if you select partner_id than you can use all partner table field as sub field

Placeholder Expression : This is the resulting expression generated when the fields are selected in Dynamic Value Builder. This can be copy pasted in fields in email template.
      ex: ${object.partner_id.email}


In Advanced tab you can find this many field:








 








Language: language of the mail
Outgoing mail server: Outgoing Mail Server configured before
Auto Delete : Permanently delete the email after sending it to save space
Attachment: to attach files on email.




Button events:


Preview: preview of mail_template
  Add context action: this creates a links in [more] in the related document model form view which helps in sending email any time from the form view.
    example: I have created a template for the sale.order and a link is created by clicking "Add Context action" button in template, a link will be created as shown below screen-shot:



















When you click on this link, a wizard pops up using from which we can send email to clicking send button:
















Thanks,

Mayur Maheshwari