Edit Email with Dynamic fields - asp.net

My website has automatic email to users and there is some dynamic fields in email text. I mean, it automatically extract name family and prefix of each user and send it them.
for example:
dear prefix name family: ->
dear Dr John Smith:
you account is active.
Now i want to add the capability of editing this email context to admin part. The problem is some fields are dynamic. my code is like this:
bodyMsg.Append( " Dear "+prefix+name+family+", thank you for accepting our request.Your username is your email and here is your Password :" + password);
As you see, name, family, prefix and password are dynamically change. Now admin needs to edit email context. He should do that from his control panel in a Rad Editor. For example change the place of name or family in email context.
What i need is when admin used key words such as prefix, name or family the system detect the dynamic fields. and the email edited with dynamic fields place.
can any body help me?
thanks

Last time I had to do something similar, I let them use predefined template-words in their text.
"Dear {prefix} {name} {family}, thank you for accepting....".
Afterwards I replaced the template-words in the text with the values.
EDIT
We do this stuff with mailtemplates that needs to be sent by an app.
The templates are created by someone and stored in the database.
They've got documentation with a list of dynamic fields they can use in the mailtemplate, like in the example below: {ReplaceWithName}.
In my app I'll replace those dynamic fields with the appropriate data:
Person person = GetPersonInfo(); //Gets the information of the person
string body = GetBodyFromDatabase(); //Retreives the created mailtemplate
body = body.Replace("{ReplaceWithName}", (person.Firstname + " " + person.Lastname)); //Do this for each dynamic field
mailMessage.Body = body;
This will of course put some responsibility to the user that creates those templates.

Related

ASP.NET Core Identity - how to use?

I want to find the user using identity.name, but if there are several users with this name, go to error.
I want to return one user using cookies, email is unique, but name not, how to use email?
enter image description here
enter image description here
enter image description here
enter image description here
As per my understanding you have something like this;
You have multiple users with the same User.Identity.Name --> How is it possible to have multiple users with the same name?
And you want to use email address instead User.Identity.Name --> If you pass email from the view to controller action, you can use something like below;
var user = await UserManager.FindByNameAsync(model.Email);

Dynamic Email Subject and Body in Docusign Powerforms in c#

Team,Docusign ,
I am using Email and Direct Mode for Powerforms in C#.NET and sending documents for signing using powerforms links and appending all custom tags as query string
for e.g.
//This is just an example, emails are sending perfectly.
demo.docusign?powerforms.aspx?id=axx-4545-a56s&Prospect_UserName={0}&Prospect_Email={1}&EnvelopeField_CompanyId={2}&EnvelopeField_StaffId={3}...
but I have a requirement where, I need to change Email Subject and Email body as per different type of companies.
For e.g. if a CompanyType: Member, then EmailSubject: "Memebers Need to Sign NDA", and Mail Body : "Dear Member, Please sign... large text"
If CompanyType :Prospect , then different wordings for Subject and Mail Body.
Right now , I have to hard code single mail wordings and bound to use same email subject and body for both types of company and I can't change it dynamically.
I don't want to create separate powerform templates again for mebertype and prospecttype and under each again one for EmailMode and another for DirectMode.
Do you have any solution ?
You could switch to using the API directly.
Powerforms don't provide the capability you're requesting.

Bigcommerce how to get query string from url to store into global variable

My task is the following, I need a way to store a query string value of s and pass it to the merchants Order Confirmation email.
consider the following,...mybigcommerce.com?s=fb.
Let's say that my client posts his website link to facebook and adds in a query string of s with a value of FB (facebook).
The desired result would be that on the initial load of the page, the query string would be saved as a cookie(or in Bigcommerce's case a global or store front variable)
Once I have it saved, I now know that you just simply append the variable to the email template.
example output:
email template source : %name_of_variable%.
My problem is, however, I don't see how to store the value into a variable.
Can I accomplish this without using the API, or for that matter can I do this using the API?
Thank you in advanced, I hope I have provided enough information.
Unfortunately, you cannot create your own variable in the email templates. The variables used here have been created and are supported by code within the core application. As such, it would require a core application change to extend existing functionality/add a variable. There isn't a way for you to write to an existing variable either.

how to remove data from an application variable

i wanted to add to my website the option of seeing the usernames of the people that are logged in my website as a list.
i did it using the Application state so when a person loges in the application variable adds it to itself.
but when a person loges out of the website i need to remove his username from the list and i'm having trouble with this... any code suggestions?
in the Login page:
Application["UserList"] += Session["UserName"].ToString() + "<br/>";
and i tried this in the Logout page but it didnt work...:
String name = Session["UserName"].ToString();
Application.Remove(name);
you would use something along the lines of this:
Application["UserList"].ToString.Replace(Session["UserName"].ToString() + "<br/>", "");
But you really should not try manage a string. Use something like a HashTable and store that object in the application state. It's far easier to manage key/value pairs in a dictionary type construct.
Also it separates the data from the formatting which gives you much greater control over the output.

ASP.NET Web Pages - Change Websecurity.currentUserName value

I am building a simple web page in ASP.NET Web Pages 2 (Razor). I have used the StarterSite template, which, by default has a registration / login system. By default you can't have a username, just an email address and password. I altered the "UserProfile" table in the database to be able to add a username for those who'd like to.
When logged in, it greets me like: "Hello, email-address" where email-address is the address you are logged in with.
In code it looks like this: "Hello, #Websecurity.currentUserName!"
Basically, what I'd like to do is that the CurrentUserName property instead of getting the CurrentUsername as the email address from the DB, get the UserName Column's value.
This is my UserProfile table structure:
Email - nVarchar(4000)
ID - int
UserName - nVarchar(4000)
How do I use this?
I managed to solve it.
You need to change the WebSecurity.InitializeDatabaseConnection method in your AppStart file like this:
WebSecurity.InitializeDatabaseConnection("Your DB Name", "Your Table Name", "What Column you want for the CurrentUserId as value", "What column you want for the CurrentUserName as value", true);
Hope this helps someone

Resources