How do you get the raw contact id from the ec_contact_id on the URL created by EXM?
We are using Sitecore's EXM to send emails containing links for surveys to recipients. When the recipient takes the survey we want to tie the response back to the recipient. Since EXM puts a unique Id, ec_contact_id, for the contact (encrypted) we want to use that to determine the recipient versus adding our own custom id.
We found this article, https://briancaos.wordpress.com/2015/04/27/sitecore-8-exm-get-the-email-recipient-from-a-sublayout/, and tried implementing it in the Sitecore controller that gets called when the recipient clicks on the link but the resulting recipient name comes back as empty. We don't have a "sc_item_id" value so we tried "_id" and "ec_message_id" in its place but neither value produced a valid contact Id or recipient name. We also tried looking in MongoDB with the decrypted contactId but couldn't find a match.
You could try somthing like this:
//get value of the ec_contact_id parameter for current request
string queryString = WebUtil.GetQueryString( Sitecore.Modules.EmailCampaign.GlobalSettings.AnalyticsContactIdQueryKey);
var shortID = ShortID.TryParse(queryString, out shortID);
System.Guid contactId;
// where initializationVector is System.Guid of your email message item.
using (var cryptoServiceProvider = new GuidCryptoServiceProvider(System.Text.Encoding.UTF8.GetBytes(GlobalSettings.PrivateKey), initializationVector.ToByteArray()))
{
contactId = cryptoServiceProvider.Decrypt(shortID.Guid);
}
When you create a new user in an email list, Sitecore creates a record in the xDB Mongo database. You should be able to get the email address from the users profile.
Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Entries[Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Preferred]
Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Entries["work_email"]
Related
I've OTRS 5 working fine . I need to retrieve information from web
for example I received emails from support team they put in the subject (customer ID) I need to put in the body message of the Ticket the customer information based on Customer ID which will fetch it from another local system through Url e.x "skldfj.com/dslkde.php?id=23487893"
for example I received ticket in subject: customer 23487893 have issue
in body need to be something like
hello team this customer (ID 23487893) have issue
customer info (fetch it from skldfj.com/dslkde.php?id=23487893)
name
telephone and more
I am having trouble figuring out how to put an unsubscribe link in my email that is SMTP integrated with Mailgun.
Any thoughts?
Mailgun provides you with several unsubscribe variables:
1) %unsubscribe_url% -- link to unsubscribe recipient from all messages sent by given domain
2) %tag_unsubscribe_url% -- link to unsubscribe from all tags provided in the message
3) %mailing_list_unsubscribe_url% -- link to unsubscribe from future messages sent to a mailing list
If you include these variables in your emails, any recipient that clicks on the url will be automatically unsubscribed and those email addresses will be blocked from receiving future emails from that domain or message tag as appropriate.
reference https://documentation.mailgun.com/user_manual.html#tracking-unsubscribes
You can use it in a href link:
Click here to unsubscribe
Instead of giving entire domain as %unsubscribe_url% , it is better to add %tag_unsubscribe_url% only, so that all the tags which are part for the current email will get unscubscribe.
Here is the code
HTML link will be like
<a style="color: #8798AD;margin: 0;text-decoration: none;" href="%tag_unsubscribe_url%">Unsubscribe</a>
This will add unsubscribe link to all tags which are part of the current send email request.
so, it my send email request has 2 tags (i.e. Orage and Mango) this two tag will get unsubscribe by mailgun.
So if you send any email which contains one of these tag, then that email will not get deliver to client.
Java code example:
String from = "alpesh#jikadra.com";
String to = "alpesh#stack.com";
String subject="Sample email";
String replyTo="no-reply#jikadra.com";
String html = "<body><h1>Hello</h1><a style="color: #8798AD;margin: 0;text-decoration: none;" href="%tag_unsubscribe_url%">Unsubscribe</a></body>";
List<String> tags = new ArrayList<String>();
tags.add("Mango");
tags.add("Orange");
MailGunRequest mailGunRequest = new MailGunRequest(from, to, subject, html, tags, replyTo);
ResponseEntity<MailGunResponse> mailGunResponseResponseEntity = mailGunClient.sendEmail(mailGunRequest);
for more reference refere : https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api
I want to know is there any way to get user subscrition / unsubscrition to email campaign ?
Is it saved in one of databases/tables in MSSQL ?
If you use the approach with opting in and out being determined on the fact if user is in role, then it is stored in the aspnet_UsersInRoles table in your core database. This table does not keep the information when role was assigned to the user. That's why you cannot get information when user subscribed or unsubscribed to email campaign.
The only thing you can check is if user is in the role:
user.IsInRole(roleName)
The user's subscription is driven by the users role, but It is possible to get the users subscriptions in ECM, You just have to use the api.
You can get the contact from the email address:
string fullName = commonDomain + "\\" + Util.AddressToUserName(username);
var contact = Contact.FromName(fullName);
var subscriptions = contact.GetSubscriptions();
Once you have a contact you can call the GetSubscriptions() method which will return the recipient lists the user is signed up to. There are a host of other methods you can call on a contact and if there is a a way to get the date unsubscribed/subscribed it will be here.
If not reflect Sitecore.EmailCampaign.dll and keep looking! There might be some extra information in the automation states table in the Analytics database. More info on automation state here:
https://www.sitecore.net/learn/blogs/technical-blogs/sitecore-magnified/posts/2013/09/ecm-automation-states-magic.aspx
Also noticed there is a method GetUnsubscribersStatistics on the Sitecore.Modules.EmailCampaign.Core.Analytics.AnalyticsHelper class. This will have the date of unsubscription.
Anyone here who has experience with using Exchange webservice.
I am trying to send an e-mail to myself using the webservice. This e-mail has another address as Sender, but it keeps taking my recipients e-mail address as Sender instead :s
This is my code:
Dim Message As MessageType = New MessageType()
Message.Subject = txt
Message.Body = New BodyType()
Message.Body.Value = ActiesOverzicht
Message.Sender = New SingleRecipientType
Message.Sender.Item = New EmailAddressType
Message.Sender.Item.EmailAddress = SenderEmail
Message.ToRecipients = New EmailAddressType(0) {}
Message.ToRecipients(0) = New EmailAddressType()
Message.ToRecipients(0).EmailAddress = RecipientsEmail
Message.Sensitivity = SensitivityChoicesType.Normal
this message goes into a list and is send with the following Code:
Public Sub SendMailToOperator(messageList As List(Of MessageType), esb As ExchangeServiceBinding)
' Create the CreateItem request.
Dim createEmailRequest As New CreateItemType()
' Specifiy how the e-mail will be handled.
createEmailRequest.MessageDisposition = MessageDispositionType.SendOnly
createEmailRequest.MessageDispositionSpecified = True
' Create the array of items.
createEmailRequest.Items = New NonEmptyArrayOfAllItemsType()
' Add the message to the array of items to be created.
createEmailRequest.Items.Items = messageList.ToArray()
'createEmailRequest.Items.Items(0) = Message
' Send a CreateItem request and get the CreateItem
' response.
Dim createItemResponse As CreateItemResponseType = esb.CreateItem(createEmailRequest)
End Sub
Does anyone have any Idea on how to solve this problem? Or what causes it?
AFAIK Exchange will normally always set the sender to the identity of the person logged in.
There are several ways around this, the easiest one being not using Exchange. Just send mail trough 'normal' SMTP.
If you have to use Exchange you should log in as the sender you're trying to use, or set up the permissions for the account you are trying to use as sender. The sender you're using should allow the account you use to login to send mail on it's behalf. The permissions can be changed through outlook.
There might also be a way to relax this restriction on the Exchange server, but I'm not an Exchange admin so I don't know how.
im sending invitation requests via the request-form to my application and i want to the sending users id from the action page. i can successfully get the ids the invitations are sent to but am not sure how to get the senders id.
im using php. this is part of my callback page:
if (isset($_REQUEST['ids'])){
$amount = sizeof($_REQUEST['ids']);
print_r($_REQUEST);
echo "<br>$amount invitations Successfully Sent";
}
the request prints out like this:
Array ( [mfs_typeahead_req_form_4cf74f96db3688507476560] => Start Typing a Name [ids] => Array ( [0] => 510149460 ) [fbs_258181898823] => \"access_token=258181898823|2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700|LqtGr_OiJTASGmek61awxmxfvFk&expires=1291280400&secret=85eTEELZj8lkV82V_PwRSA__&session_key=2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700&sig=d4cc0e4c0992ea29c0adfd60dc27185b&uid=100000664203700\" )
the id i want is 100000664203700
If using requets 2.0 http://developers.facebook.com/docs/reference/dialogs/requests/
You can get the user id form current session and append to the data parameter in the request. Facebook will send the data though as a string and you can extract on the redirect uri.
as per your print_r() Have you tried json decoding the $_REQUEST? This will give you an array to work with and you can do a quick search for uid= in your string.
http://php.net/manual/en/function.json-decode.php