I looking to change the display name in a Email using MVCMailer. Instead of the client seeing From: custmerservice#xyzCompany.com they will see "xyzCompany Customer Service".
I have looked all around the internet and can not find any documentation that explains how.
USERMAILER.CS
public virtual MvcMailMessage Welcome(string sentTo, string replyTo)
{
return Populate(x =>
{
x.Subject = "Welcome";
x.ViewName = "Welcome"; //View name of email going out.
x.ReplyToList.Clear();
x.ReplyToList.Add(replyTo);
x.To.Add(sentTo);
x.From.DisplayName("xyz Company Customer Service");
x.From = new MailAddress("customerservice#xyzCompany.com");
x.ViewName = "WelcomeEmail"; //View name of email going out.
});
}
The line 'x.From.DisplayName("xyz Company Customer Service")' gives me an error: system.net.mail.mailaddress.DisplayName can not be used as a method.
Can anyone please tell me how to properly change the displayname?
DisplayName is a property of the MailAddress class. You can use this overload of the constructor to specify it:
x.From = new MailAddress(address: "customerservice#xyzCompany.com", displayName: "xyz Company Customer Service");
Update based on comment:
The DisplayName property has no (or a private) setter, meaning you can only set it through the constructor of MailAddress, but not through the property itself.
Related
I need to create an interface from a Hotel PMS application to a Broadworks PBX using OCI. I am on the hotel PMS side. I have located broadworks-connector-net
1: https://github.com/cwmiller/broadworks-connector-net and I am trying to work my way in
The objective is whenever a room is checked in in the PMS application, to get the extension and instruct the PBX to open the line and assign the name of guest in it (so the receptionist can see who is calling from each room).
I have found no API manual and the Cisco sandbox is not open.
So I am working "theoretically" until I get access to the actual PBX
I have assembled this code in order to find the Extension 200. I do not even know if I am searching inside the correct Model.
var req1 = new BroadWorksConnector.Ocip.Models.UserPhoneDirectoryGetListRequest
{
SearchCriteriaExtension = new List<BroadWorksConnector.Ocip.Models.SearchCriteriaExtension>
{
new SearchCriteriaExtension
{
IsCaseInsensitive = false,
Mode = BroadWorksConnector.Ocip.Models.SearchMode.EqualTo,
Value = "200"
}
}
};
try
{
var response = await ocip.CallAsync(req1);
foreach (var row in response.DirectoryTable.Row)
{
Console.WriteLine(row.Col[0]);
}
}
catch (BroadWorksConnector.Ocip.ErrorResponseException ej)
{
SetText(ej.Message.ToString());
}
catch (ValidationException ek)
{
SetText(ek.Message.ToString());
}
Now that I theoretically have the Extension, how can I make the PBX assign a Name on that Extension and open it so it can be usable by the guest?
For the Name part, I have found the GroupVirtualOnNetEnterpriseExtensionsModifyUserRequest but I do not understand how can I set the Name for a specific Extension.
var req2 = new BroadWorksConnector.Ocip.Models.GroupVirtualOnNetEnterpriseExtensionsModifyUserRequest
{
ServiceProviderId = "test-service-provider",
GroupId = "test-group",
CallingLineIdFirstName = "Smith"
};
Generally I cannot understand how can I use this API to selectively modify a value in a model (eg to assign Smith to PhoneNumber 200 or to assign John into Device 234)
Any help appreciated.
Thank you
So, I'm trying to change the nickname on the bot to the username of the command sender (?) So here is what I got going now but it changes the name to the id of the user?
commands.CreateCommand("tts")
.Parameter("userMsg", ParameterType.Unparsed)
.Do(async (e) =>
{
var server = _client.GetServer(*server id*);
var user = server.GetUser(_client.CurrentUser.Id);
await user.Edit(nickname: e.User.Mention);
string UserMsg = e.GetArg("userMsg");
await e.Channel.SendTTSMessage(UserMsg);
});
}
What I got going now only changes the bots name to the userid but I don't want that? I've also tried to search around but can't really find anything?
Thanks in advance!
Change e.User.Mention to e.User.Name
When I execute the below code, the mail id is not added to the list, but the "result" parameter contains the value of Email,EUIdl, LEId. Anyone can give the exact code. The code taken from
https://github.com/danesparza/MailChimp.NET
MailChimpManager mc = new MailChimpManager("5323a23b12022d250c23c48253641dd5-us8");
// Create the email parameter
EmailParameter email = new EmailParameter()
{
Email = "riyas.k13#gmail.com"
};
EmailParameter results = mc.Subscribe("33cacee7d8", email);
With the MCAPI this is the call to subscribe to a list, you might want to check all the options in the subscribeOptions, and determine your required Merge values
MCApi mc = new MCApi(ConfigurationManager.AppSettings["MCAPIKey"], false);
var subscribeOptions = new Opt<List.SubscribeOptions>(new List.SubscribeOptions { SendWelcome = true, UpdateExisting = true });
var merges = new Opt<List.Merges>(new List.Merges { { "FNAME", [Subscriber FirstName here] }, { "LNAME", [Subscriber lastName here] } });
if (mc.ListSubscribe(ConfigurationManager.AppSettings["MCListId"], [Subscriber email ], merges, subscribeOptions))
// The user is subscribed Do Something
I had the same issue where the code seemed to work but no email was added to the list. The code does work by the way.
When a new email address is added to the mail list MailChimp sends out a confirmation email to that address, which you need need to confirm naturally.
If you don't do this the new email address won't be added to the list. If you didn't receive any email at the target address check the spam folder or see if any filters have accidentally caught it without you realising.
Sad to say I spent a good few hours going around in circles because of this.
This depends on maichimp list setting when you created the list. There is something called "ask users to confirm the subscription". By default, if admin checked this option, after importing, the users will receive confirmation emails. New added user names will be added only if they confirmed.
If you don't want to sent confirmation emails but directly added new users. Set "DoubleOptIn" to false.
/*
Set subscribe options
*/
MailChimp.Types.List.SubscribeOptions option = new MailChimp.Types.List.SubscribeOptions();
option.UpdateExisting = true;
option.DoubleOptIn = false;
List<MailChimp.Types.List.Merges> lstMerges = new List<MailChimp.Types.List.Merges>();
/*
Merge new users here.
*/
returnStatus = api.ListBatchSubscribe("your MailChimp List ID", lstMerges, option);
is it a bug in outlook?
i've created a local Contact list card, and i gave him in the address field an exchange user address. (double click on that address, see that its exchange).
when i try to get the address using MAPI - i can't, the problem is this, when i check the AddressEntry object, i get the following:
Type = "EX"
Address = "/o=.../ou=Exchange..."/cn=Recipients/cn=Name
Class = olAddressEntry
AddressEntryUserType = olOutlookContactAddressEntry
when i checked in OutlookSpy - no MAPI properties, so i can't get PR_SMTP_ADDRESS nor PR_EMS_AB_PROXY_ADDRESSES, also, this is not SMTP so i have no valid address.
i checked other users and those are the properties (which it works):
Real exchange user recipient, same email address as the exchange one, but it was created without autocorrect to the exchange user, so it stays smtp:
Type = "SMTP"
Address = "Email#email.com"
Class = olAddressEntry
AddressEntryUserType = olExchangeUserAddressEntry
Regular address entry
Type = "EX"
Address = "/o=.../ou=Exchange..."/cn=Recipients/cn=Name
Class = olAddressEntry
AddressEntryUserType = olOutlookContactAddressEntry
if i double click on the "exchange" local contact, it opens exchange window of its properties, if i open the "regular one i created manually", it opens the "SMTP" address window.
any workaround i can do?
thanks.
It didn't work in way "Dmitry Streblechenko" suggested because for some reason
ContactItem.Email1EntryId, ContactItem.Email2EntryId and ContactItem.Email3EntryId contains not id but some wrong random data (even some html tags) - office 2016.
But it finally worked with following code
using (var pa = new InteropWrapper<Outlook.PropertyAccessor>(contact.innerObject.PropertyAccessor))
{
String EMAIL1_ENTRYID = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80850102";
string emailEntryID = pa.innerObject.BinaryToString(pa.innerObject.GetProperty(EMAIL1_ENTRYID));
using (var rs = new InteropWrapper<Outlook.NameSpace>(Globals.ThisAddIn.Application.Session))
{
rs.innerObject.Logon();
using (var addressEntry = new InteropWrapper<Outlook.AddressEntry>(rs.innerObject.GetAddressEntryFromID(emailEntryID)))
using (var exchangeUser = new InteropWrapper<Outlook.ExchangeUser>(addressEntry.innerObject.GetExchangeUser()))
{
return exchangeUser.innerObject.PrimarySmtpAddress;
}
}
}
where InteropWrapper<T> just IDisposable wrapper around com object - it does Marshal.ReleaseComObject(innerObject) on dispose. So you can do everything without it by using Marshal.ReleaseComObject() directly.
just in case if someone need email 2 and email 3 including them here
String EMAIL2_ENTRYID = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80950102";
String EMAIL3_ENTRYID = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80A50102";
Hope it will save someones time! I've spent like a day on it.
If you have an EX type contact, use the value of the ContactItem.Email1EntryId property to call Namespace,GetAddressEntryFromId, then read the AddressEntry.GetExchangeUser.PrimarySmtpAddress property.
We are working on implementing some custom code on a workflow in a Sitecore 6.2 site. Our workflow currently looks something like the following:
Our goal is simple: email the submitter whether their content revision was approved or rejected in the "Awaiting Approval" step along with the comments that the reviewer made. To accomplish this we are adding an action under the "Approve" and "Reject" steps like so:
We are having two big issues in trying to write this code
There doesn't seem to be any easy way to determine which Command was chosen (the workaround would be to pass an argument in the action step but I'd much rather detect which was chosen)
I can't seem to get the comments within this workflow state (I can get them is the next state though)
For further context, here is the code that I have so far:
var contentItem = args.DataItem;
var contentDatabase = contentItem.Database;
var contentWorkflow = contentDatabase.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//contentWorkflow.GetCommands
var status = contentWorkflow.GetState(contentHistory[contentHistory.Length - 1].NewState);
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
//approve/reject comments
var message = contentHistory[contentHistory.Length - 1].Text;
//sitecore user (so we can get email address)
var submittingUser = sc.Security.Accounts.User.FromName(lastUser, false);
}
I ended up with the following code. I still see no good way to differentiate between commands but have instead implemented two separate classes (one for approve, one for reject):
public void Process(WorkflowPipelineArgs args)
{
//all variables get initialized
string contentPath = args.DataItem.Paths.ContentPath;
var contentItem = args.DataItem;
var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
var status = "Approved";
var subject = "Item approved in workflow: ";
var message = "The above item was approved in workflow.";
var comments = args.Comments;
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
var submittingUser = Sitecore.Security.Accounts.User.FromName(lastUser, false);
//send email however you like (we use postmark, for example)
//submittingUser.Profile.Email
}
}
I have answered a very similar question.
Basically you need to get the Mail Workflow Action and then you need to further extend it to use the original's submitter's email.
Easiest way to get the command item itself is ProcessorItem.InnerItem.Parent
This will give you the GUID for commands like submit, reject etc.
args.CommandItem.ID
This will give you the GUID for states like Draft, approved etc.
args.CommandItem.ParentID