Adding Email Queue Item to Queue from Contact - How can i put the Contact in From Field?

Hi Guys,
A contact completes our webform on our website. The comments box text on the webform goes into a hidden comments box on the contact form which in turn triggers a workflow to create an email message and queue item which adds the email message to a queue for
a response from one of the sales team. I am unable to populate the 'From' field on the email message with the Regarding Contact or Contact details in order for me to be able to just hit reply to answer the query.
Any ideas on how i can acheive this?
Thanks
Dave
David Kelly

Hi  David using Custom Workflow you can achieve this . Below is the sample code.
protected override void Execute(CodeActivityContext executionContext)
//Create the tracing service
try
//Create the context
IExecutionContext context = executionContext.GetExtension<IExecutionContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
ITracingService tracer = executionContext.GetExtension<ITracingService>();
bool isEmailmatches = false;
EntityReference incident = EmailActivityLookup.Get(executionContext);
RetrieveRequest request = new RetrieveRequest();
request.ColumnSet = new ColumnSet(new string[] { "from", "description", "subject" });
request.Target = new EntityReference("email", incident.Id);
string email = string.Empty;
string senderqueue = string.Empty;
string senderqueueFOC = string.Empty;
bool senderqueueOutput = false;
bool senderqueueOutputFOC = false;
Guid SenderQueueId = Guid.Empty;
Entity entity = (Entity)((RetrieveResponse)service.Execute(request)).Entity;
EntityCollection IncommingParty = null;
IncommingParty = (EntityCollection)entity["from"];
for (int i = 0; i < IncommingParty.Entities.Count; i++)
if (IncommingParty != null && IncommingParty[i].LogicalName
== "activityparty")
EntityReference PartyReference =
(EntityReference)IncommingParty[i]["partyid"];
// Checking if email is sent by CRM Account
if (PartyReference.LogicalName == "systemuser")
// Retrieve sender Account record
Entity User = service.Retrieve("systemuser",
PartyReference.Id, new ColumnSet(true));
// wod_Account = new Entity("account");
email = User.Attributes["internalemailaddress"].ToString();
if (email.Contains("[email protected]") == true)
senderqueue = "Tier 1 Email";
if (email.Contains("ford.com") == true)
senderqueue = "Tier 1 Email";
if (email.Contains(".ca") == true)
senderqueueFOC = "FOC Tier 1 Email - English ";
if (email.Contains("icollection.com") == true)
senderqueue = "Tier 1 Email";
QueryByAttribute querybyattribute2 = new QueryByAttribute("queue");
querybyattribute2.ColumnSet = new ColumnSet("name", "queueid");
querybyattribute2.Attributes.AddRange("name");
// Value of queried attribute to return.
querybyattribute2.Values.AddRange(senderqueue);
EntityCollection retrieved2 = service.RetrieveMultiple(querybyattribute2);
foreach (var c in retrieved2.Entities)
// string Queueid = c.Attributes.Contains("queueid").ToString();
SenderQueueId = c.GetAttributeValue<System.Guid>("queueid");
if (senderqueue != null && senderqueue != string.Empty)
senderqueueOutput = true;
if (senderqueueFOC != null && senderqueueFOC != string.Empty)
senderqueueOutputFOC = true;
this.OutSenderSearchFOC.Set(executionContext, senderqueueOutputFOC);
this.OutSenderSearch.Set(executionContext, senderqueueOutput);
catch (Exception ex)
Helpers.Throw(String.Format("An error occurred in the {0} Workflow.",
this.GetType().ToString()),
ex);
[ReferenceTarget("email")]
[Input("EmailActivity")]
public InArgument<EntityReference> EmailActivityLookup { get; set; }
[Output("OutSenderSearch")]
public OutArgument<bool> OutSenderSearch { get; set; }
[Output("OutSenderSearchFOC")]
public OutArgument<bool> OutSenderSearchFOC { get; set; }
Here i am doing many things but you can see how to rerieve data from  activity party. Please let me know for any clarification.
Abhishek

Similar Messages

  • How can I print the contacts in Backup Assistant?

    To have a hard copy of all my contacts, how can I print the contacts in my Backup Assistant?

    The Backup Assistant only allows you to print each contact card separately.  The simplest way to get all the contacts printed out is to Export them all to a csv file (Excel) and delete or hide the fields you don't need before printing (there are a lot of extra fields.
    Click the checkmark to expand the box, then click the three vertical dots to get the choice to Export all.

  • I have 528 contacts on my phone, but only 290 on my Icloud how can i move the rest over from my phone to my Icloud nothing is working

    I have 528 contacts on my phone, but only 290 on my Icloud how can i move the rest over from my phone to my Icloud nothing is working

    Go to Settings>iCloud, turn Contacts to Off, choose Delete from My iPhone when prompted (they will still be in iCloud).
    Download the app My Contacts Backup to your phone.  Use this app to backup the remaining contacts on your phone (from your exchange account) as a vCard attachment to an email that you send to yourself.  Confirm that you have received the email on your phone.
    Go to Settings>iCloud and turn Contacts back to On.
    Go to Settings>Mail,Contacts,Calendars>Default Account (in the Contacts section), set this to iCloud.  (This will cause new contacts added to your phone to be added to the iCloud account.)
    Go to Settings>Mail,Contacts,Calendars...tap your exchange account and turn off contacts syncing (otherwise you will end up with duplicates on your phone).
    Open the My Contacts Backup email and tap the attachment to import the contacts from your exchange account back to your phone.  They will be added to iCloud and appear on icloud.com and any other devices syncing contacts with your account.

  • I inadvertinly removed my contacts from my Address app on my iPad. it is still on our other iPad and our two iPhones. How can I import the contacts back into our iPad

    I inadvertinly removed my infocontact information  from my wikes "Contacts" App. The contact app still works in my iPad and both of our iPhones..
    How can I restore the contact info in her Contact app??
    Thanks

    Have you tried syncing them across iCloud? There is a nice tutorial here: http://www.gottabemobile.com/2011/10/18/how-to-sync-email-contacts-and-calendar- with-icloud/

  • HT204053 I am using my Apple ID for me and for my wife. when I sync. the phones i lost all my wife contact. how do i recover the contact from i cloud?

    I am using my Apple ID for me and for my wife. when I sync. the phones i lost all my wife contact. how do i recover the contact from i cloud?

    While I have a few ideas, I think you'd have better luck troubleshooting this in the iCloud forum.

  • HT1670 how can I copy the contact from iphone 2G first iphone

    how can I copy the contacts from iphone 3g

    Sync them to an app/progra/servie like Google contacts.
    iTunes 11 for Windows: Sync contacts, calendars, and other info with iPod, iPhone, or iPad
    ALso see:
    iPhone Transfer Contact - Transfer - levesoft, iPod/iPhone/iPad/Windows/Mac/PDF software free download

  • How can I transfer the contacts from my ipad to my itouch ?

    How can I transfer the contacts from my ipad to my itouch?

    Precisely what adami said. Hook up your ipad to your computer. Under 'info' choose to sync contacts. That will put them on your computer. Then plug in your Touch and choose the same, to sync contacts with the computer, and they'll transfer.
    Alternatively you can go into each contact and choose to 'share' it and mail it to an account that you can access on your Touch, then open it and save it. Upside, no computer needed, downside, it's a bit tedious.
    Theoretically you can also use iCloud, however the cloud ate my contacts so I'm not syncing via the cloud for that anymore. Your experience might be different, but I personally would avoid the cloud unless you've got them all backed up somewhere in case the cloud eats yours too.

  • How can I transfer the contact from iPhone to iPad Air?

    How can I transfer the contact from iPhone to iPad Air?

    Use airdrop
    http://ipad.about.com/od/iPad_Guide/ss/What-Is-Airdrop-How-Does-It-Work_2.htm

  • How can I sync the contacts in my phone with those on my MacBook Pro? I already have an iCloud account, and everything else (calendars,music, etc.I is already synched) but the contacts won't.

    How can I sync the contacts in my phone with those on my MacBook Pro? I already have an iCloud account, and everything else (calendars,music, etc.I is already synched) but the contacts won't.

    Ok.
    Open System Preferences, Apple Logo icon in the menu bar and then System Preferences or the Sys Pref iocon in the Dock and go to the Internet Accounts area and look at your iCloud account. It should list what is and isn't synced by a checkmark next to each item.
    Also in the Contacts app click on Contacts in the menu bar and select Preferences then accounts and make sure your iCloud account is listed. You can also do that from the Internet Accounts area in System Preferences.

  • How can i disable the credit card from that stolen acc and register to my new account

    Hello everywone i have a big problem.. Somewone stole my apple id and changed everything (email , secret question). In that account was my credit card registered. how can i disable the credit card from that stolen acc and register to my new account ?? thanks for help

    Is it an IMAP or POP account?
    For POP accounts, you can select remove from server under the advanced tab of the account.
    Apple support article with information on receiving a message more than once:
    Mail Problems

  • HT3702 how can i remove the authorization hold from my card...

    how can i remove the authorization hold from my card

    You can try contacting iTunes support : http://www.apple.com/support/itunes/contact/ - click on Express Lane, then iTunes > iTunes Store
    How much was the amount ? A 'normal' holding charge is a small amount (e.g. equivalent to about $1), and usually happens after you add or change credit card details on your account. Here in the UK it can take a few working days for it to disappear (so a weekend can extend the elapsed time).
    Edit : I don't know what a non-liability certificate is and/or whether Apple can do one.

  • How can I remove the background sound from the headphone jack for my MacBoo

    for my MacBook Air problem adding music intensifier (Panasonic ST-HT1000) to give it an unpleasant sound background that sounds like a whiz, it's not so loud, but it is an unpleasant .. after a short time can get used to, but the fizz does not pass, however, believe that it is a big problem.
    Further I notice that when MacBookAir disconnected from the charger, it remains quieter sound.
    At first thought that the headphone jack (3.5 mm Headphone:
    Connection: 1/8-Inch Jack) or wiere have problem, but tried 3 different cables, but that does change enything, the problem remains.
    When I added iPhonu3GS playing - the background sound were not, then everything is OK!
    How can I remove the background sound from the headphone jack for my MacBook Air 13?

    There is no way to bring that up unless you have it typed in a document. You can use My Support Profile to find a list of serial numbers that have been purchased or registered with your Apple ID.
    http://support.apple.com/kb/HT2526?viewlocale=en_US 
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD  240G Vertex 3 SSD Boot HD 

  • How can I remove the moon phases from iCal?

    I need to remove ALL the moon phases that appear in iCal 5.0.3. Every time iCloud updates it sends 6 to 10 moon events to my MacBook Pro. Going forward 3 0r 4 months, there are too many moon phases. How can I remove the moon phases from iCal?
    I am on a MacBook Pro 2.2 with 4 GB using Mountain Lion 10.7.5.

    Try:
    items.RemoveAll(s => string.IsNullOrEmpty(s));
    Or you can filter them out using where:
    var noEmptyStrings = items.Where(s => !string.IsNullOrEmpty(s));
    Having fun with custom collections!
    Basics of .NET Collections in C#
    How does it work in C#? - Part 3 (C# LINQ in detail)
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • How can I remove the " Source.vi" from long Express VI Names?

    I am in the Moment working on the Development of an Express VI
    library for test purposes.
    How can I remove the " Source.vi" from long Express VI Names?
    This happens when the Express VI is inserted in the blockdiagram
    and listed in LabVIEW and TestStand Palettes.
    By short names like "DAQ-Assistent" or "EasyCalc" the string " Source.vi"
    is not shown at the end of the Express VI names.
    I used The Express VI Dev Toolkit 1.0 to create the Express VIs.
    Labview Version: 7.1 Base
    TestStand: 3.1
    It would be great to get the expert advice from the Forum for this issue!
    Thanks a lot.
    Andre

    I think I understand what you are asking for. If I am wrong, please try to explain it a bit more.
    The name shown may be different than the name of the vi file. To do this, your source VI and popup on its icon. From the short menu that comes up, select VI properties. In the top ring, select Window Appearance. The page that comes up lets you set various things that can affect the appearance of the VI. What you want to change is the window title. Uncheck the Same as VI name checkbox and change the string to whatever you want it to be.
    I hope that this helps,
    Bob
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • How can we prepare the PDC Cheques from SAP?

    Hi,
    How can we prepare the PDC Cheques from SAP?
    tx
    Bharat

    Dear:
                For catering PDCs in SAP there is a standard procedure. First you book PDC down payment request through F-37 which is mostly done with reference to invoice( A request is a notional entry having no financial impact). After realizing the check at due date you post it through F-29 and clear the customer afterwords through F-32. For configuration you must define Special GL indicator in FBKP for customers and mark it as noted item.
    Regards

Maybe you are looking for

  • Financial Reporting 9.3.1 error with related content

    Hi All, I need some help with the below issue please: We are on 9.3.1. We have a financial reporting report which contains related content that opens up in a new window and pulls an Interactive Reporting bqy. The data in the related content report is

  • Cant connect to iTunes store to authorize my pc due to (-3212) error that i get whenever i get into iTunes, what can i do?

    Can't connect to iTunes store to authorize my pc due to (-3212) error that I get whenever I get into iTunes, what can i do? I have no internet connection problems.

  • BADI or User Exit for F-47 or F-48

    Hello Friends, I have to validate the Amount which was posted in F-47(Down Payment Request) in the F-48(post vendor Downpayment )... i got 14 Exits and 26 Badis but no one is calling.... I have put break-point in all the exit and badi.... but no resu

  • Problem in setting the resultset recordset

    hi all, i am trying to do paging in my website .. i want to set the records fetched from the resultset...i am using the "rs.setFetchSize(3)" i want to show only 3 records per page... code is shown below.. problem is it is showing "java.sql.SQLExcepti

  • What to buy for TurboTax

    Each year, I do my business taxes using TurboTax for Business. This is not for Schedule C companies, but for C and S - Corps that file the 1120 form. This version is only available for Windows computers. The last few years, I borrowed a PC. Before th