The createEmail() method creates the specified email.If you have been using the deprecated createEmailCampaign function, we’ve put together a brief guide to help you switch to createEmail.
Input
session_id [xsd:string] (required)
Your API session id.
email [vrtypens:Email] (required)
An Email object representing the new email.
The following fields are required to be passed with createEmail:
The following fields are required to be passed with createEmail:
- name: A unique string used to identify your campaign.
- email_type: The type of email you are creating, which must be one of the following:
- canvas: Editable using the Canvas Editor in the VerticalResponse web application.
- freeform: Fully-formed HTML/Text; can be edited in the VerticalResponse application using the non-WYSIWYG editor.
- freeform_text: Fully-formed text-only email; can be edited in the VerticalResponse application using the non-WYSIWYG editor.
- from_label: The name this email should appear to be sent from. This value is usually displayed in the recipient’s email client instead of the actual “from” email address and will be appended to mail.vresp.com. For example, the from_label of “Apple Pie, Inc” will create a from address of apple_pie_inc@mail.vresp.com.
- reply_to_email: The email address to which replies to this email will be sent. We filter automatic replies (like out of office replies) and forward unique responses to this email address.
- subject: The subject of the email.
If your user will not use the VerticalResponse web application to launch the email, we recommend setting the following attributes to true. Emails will not launch if any of the following attributes is set to false:
- previewed_html: Whether the email should be considered to have had its HTML version previewed. Defaults to false; can only be toggled to True via the VerticalResponse web application.
- previewed_text: Whether the email should be considered to have had its text version previewed. Defaults to false; can only be toggled to True via the VerticalResponse web application.k
- tested: Whether the email should be considered to have been tested. Defaults to false; is toggled to true if sendEmailCampaignTest has been called on the email.
Output
[xsd:int]
The output is the campaign ID of the new email.
Examples
PHP
$email = array( 'name' => "PHP Test " . time(), 'email_type' => "canvas", 'from_label' => "VerticalResponse PHP Sample Code", 'reply_to_email' => $username, 'subject' => "VerticalResponse API Test Email", 'freeform_html' => "<html><body><h1>Hello, World!</h1><p>This HTML email was created using the VerticalResponse API PHP createEmail code snippet.</p></body></html>", 'freeform_text' => 'Hello, World! This text email was created using the VerticalResponse API createEmail code snippet.', 'send_friend' => 'True', 'hosted_email' => 'True', 'previewed_html' => 'True', 'previewed_text' => 'True', ); $cid = $vr->createEmail( array( 'session_id' => $sid, 'email' => $email, ) );
Ruby
email = { 'name' => "Ruby Test "+ DateTime.now.to_s, 'email_type' => "canvas", 'from_label' => "VerticalResponse Ruby Sample Code", 'reply_to_email' => username, 'subject' => "VerticalResponse API Test Email", 'freeform_html' => "<html><body><h1>Hello, World!</h1><p>This HTML email was created using the VerticalResponse API Ruby createEmail code snippet.</p></body></html>", 'freeform_text' => 'Hello, World! This text email was created using the VerticalResponse API Ruby createEmail code snippet.', 'send_friend' => true, 'previewed_html' => true, 'previewed_text' => true, 'tested' => true, } cid = vr.createEmail({ 'session_id' => sid, 'email' => email })
Java
Email email = new Email (); email.setName ("Java Test " + System.currentTimeMillis()); email.setEmail_type("canvas"); email.setFrom_label ("VerticalResponse Java Sample Code"); email.setReply_to_email(USERNAME); email.setSubject("VerticalResponse API Test Email"); email.setFreeform_html("<html><body><h1>Hello, World!</h1><p>This HTML email was created using the VerticalResponse API Java createEmail code snippet.</p></body></html>"); email.setFreeform_text("Hello, World! This text email was created using the VerticalResponse API Java createEmail code snippet."); email.setTested(true); email.setPreviewed_html(true); email.setPreviewed_text(true); CreateEmailArgs createEmailArgs = new CreateEmailArgs( sessionID, email ); campaignID = vr.createEmail( createEmailArgs );
C#.NET
Email objEmail = new Email(); objEmail.name = "C# Test: " + date; objEmail.from_label = "VerticalResponse C# Sample Code"; objEmail.reply_to_email = objLA.username; objEmail.subject = "VerticalResponse API Test Email"; objEmail.email_type = "canvas"; objEmail.freeform_html = "<html><body><h1>Hello, World!</h1><p>This HTML email was created using the VerticalResponse API C#/.NET createEmail code snippet.</p></body></html>"; objEmail.freeform_text = "Hello, World! This text email was created using the VerticalResponse API C# createEmail code snippet."; objEmail.previewed_html = true; objEmail.previewed_htmlSpecified = true; objEmail.previewed_text = true; objEmail.previewed_textSpecified = true; objEmail.tested = true; objEmail.testedSpecified = true; createEmailArgs objCE = new createEmailArgs(); objCE.session_id = sessionId; objCE.email = objEmail; int intcampaignId = 0; try { intcampaignId = objVR.createEmail(objCE); } catch (Exception e) { System.Console.WriteLine(e.Message); }