Results 1 to 2 of 2

Thread: Send email to Contact when a Case is created

  1. #1
    MichaelRLevy is offline Junior Member
    Join Date
    Jul 2007
    Posts
    6

    Cool Send email to Contact when a Case is created

    I'm a PHP programmer, but am new to SugarCRM. I'm using Open Source 4.5.1e. I'm just starting to learn about the SOAP API, custom hooks, and Sugar beans.

    I've written web forms (outside SugarCRM) that allows a person to create one or more research requests. The person's contact information goes into a Sugar Contact, and each research request goes into a Case. My app then uses SOAP and creates the Contact and Case(s) and links them together in SugarCRM.

    I've made a custom hook on the Case, and it gets invoked when each Case is created. It's working and I can, for example, log the $bean->contact_id value associated with the Case.

    Now, the hard part. I need to do the following in the logic hook:

    (a) compose a customized email confirmation for the user that contains the Contact's information and the Case
    (b) send the email from SugarCRM in such a way that it's attached to the Case

    I think I could figure out how to do a sql query to get the Contact information. But at this point I don't know anything about how to send email (other than to a user). Thanks in advance!
    Last edited by MichaelRLevy; 2007-09-27 at 04:00 PM.

  2. #2
    julian's Avatar
    julian is offline Sugar Team Member
    Join Date
    Sep 2004
    Posts
    1,639

    Default Re: Send email to Contact when a Case is created

    Hello MichaelRLevy,

    First off, I'm moving this thread to the Developers forum, where you'll get some more relevant answers.

    Instead of doing a direct SQL query to retrieve Contact information, I suggest you instantiate a Contact object, ala:

    PHP Code:
    require_once('modules/Contacts/Contact.php');
    $contact = new Contact();
    $contact->retrieve($bean->contact_id); // you now have access to all the Contact information in this object 
    If you want an Email record attached your Case, you'll need to create it first. The process is similar:

    PHP Code:
    require_once('modules/Emails/Email.php');
    $email = new Email();

    $email->case_id $bean->id;
    $email->body "...";
    // etc. etc. etc.

    $email->save(); 
    You'll need to check the properties of the Emails module and figure out which fields are required. Last, you'll need to check the code that normally sends Emails and transplant that into your logic hook.

    Let me know if you run into any problems! Good luck,
    Julian Ostrow
    Systems and Applications Engineer
    SugarCRM Inc.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HOW-TO guide for Email Campaigns.
    By agupta in forum Marketing/Campaign Management
    Replies: 146
    Last Post: 2012-01-31, 03:08 PM
  2. Replies: 15
    Last Post: 2010-04-01, 04:04 PM
  3. Replies: 9
    Last Post: 2007-06-04, 07:50 PM
  4. Assign a new case to a Contact not an Account
    By digitalfriction in forum Help
    Replies: 1
    Last Post: 2007-01-15, 08:39 AM
  5. Replies: 0
    Last Post: 2006-06-20, 11:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •