SWS SendEmailContact Method
Sends an email via eStore requesting a contact from the site manager. The organization can create custom templates, but this method does not currently support them.
Parameters
Name | DataType | Is Required |
---|---|---|
String | Required | |
Description | The sender’s email address. | |
EmailType | emailMsgTemplateIds | Required |
Description | Indicates what template the email will use. Available values:
(Other templates are not available with this method.) |
|
Message | String | Required |
Description | The sender’s message to the site manager. | |
Name | String | Required |
Description | The sender’s name. | |
OrgID | Long | Required |
Description | The organization’s ID number. | |
SiteID | Long | Required |
Description | The site’s ID number. This can be found using the GetSiteList method. | |
Telephone | String | Optional |
Description | The sender’s phone number. | |
UnitNumber | String | Optional |
Description | The unit’s number as assigned by the organization to which the email refers. This is not the UnitID. |
Returned Parameters
Name | DataType |
---|---|
SentResponse | String |
Description | The email message ID if successful, or an error message if it failed to send. |
Example
As with every method we need to pass in credentials. We do this with the LookupUser request object.
We will assume you have a web reference, let us name it SWS, in your Visual Studio project. At this point we need to define our objects. We will need the standard service object, a SendEmailContact request object, and a SendEmail response object. We can define and create those like this:
// Create a request and response objects
SWS.WSSoapClient service = new SWS.WSSoapClient(); SWS.SendEmailContact_Request request = new SWS.SendEmailContact_Request(); SWS.SendEmail_Response response;
Here is a sample code of the request object:
// SendEmailContact Request
request.OrgID = 123456;
request.SiteID = 123456;
request.Email = "j.doe@a.c";
request.EmailType = SWS.emailMsgTemplateIds.SWS_CONTACT_SITE;
request.Name = "John Doe";
request.Telephone = "800-555-1212";
request.UnitNumber = "A1";
request.Message = "I have a question about a letter I received from you.";
Finally we can call the method and pass across the login object and the request object to retrieve our requested information. It’s a good idea to do this in a Try Catch block.
// Call the method that will load the response object
try
{
response = service.SendEmailContact(user_request, request);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Note that if something goes wrong the service will respond with an exception. You will want to capture the message in the exception so it can be debugged.
For a full list of methods see SWS Methods.