hai Friends
I am using this coding for validating the emailID online through webservice method.i will get a input a from a textboa and the click the button.but it is validating the emailId only one at a time.how to vaildate multiple EmaiIDs and validate and return the values.or how to split the ids and validate let me know.
The webservice link is http://www.webservicex.net/ValidateEmail.asmx?wsdl
So far my coding is
protected void ValidateEmail_Click(object sender, EventArgs e)
{
ValidateEmail.ValidateEmailSoapClient EmailClient = new ValidateEmail.ValidateEmailSoapClient("ValidateEmailSoap12");
bool bval = System.Convert.ToBoolean(EmailClient.IsValidEmail(txtvalidateEmail.Text));
Response.Write("Email Address is " + bval.ToString());
}
The link you've posted doesn't open here but I will try to answer your question. If the web service has another method that allows you to pass multiple email addresses then you can use this method. If not, you will need to call the web service for each email you are trying to validate which of course might not be very efficient.
Related
I've using a custom GetMailTips SOAP call (since the EWS for Core 2.0 doesn't support it) to get Out of Office info for a batch of email addresses.
How can I get the display names of the users that I am passing in the email address for?
I can call ResolveName of the managed API and that works but it has to be done one at a time and that is slow. I would like to ideally get this info out when I make my GetMailTips request and failing that make a call with all the email addresses to get the Display Names all at once. I read there is meant to be a ResolveNames method but that's not in the API either.
Any help appreciated
Autodiscover can return that for multiple users eg
AutodiscoverService adService = new AutodiscoverService(ExchangeVersion.Exchange2013_SP1);
adService.Credentials = new NetworkCredential("user#d.com", "pass");
adService.RedirectionUrlValidationCallback = adAutoDiscoCallBack;
List<String> Users = new List<string>();
Users.Add("user1#domain.com");
Users.Add("user2#domain.com");
GetUserSettingsResponseCollection usrSettings = adService.GetUsersSettings(Users, UserSettingName.UserDisplayName);
foreach(GetUserSettingsResponse usr in usrSettings)
{
Console.WriteLine(usr.Settings[UserSettingName.UserDisplayName]);
}
Another way would be to create a Message and add the email address as recipients then save it to the drafts folders and the address should get resolved against the GAL.
I have been researching up creating my own link to PayPal, that when a person is logged in, it will generate a "specified email" in the "To:" text box on the form.
However, I am planning something a tad more ambitious; I'd like to know it is possible to build this link in my code to where the specified email "cannot be edited or changed?" Again, this would coming from my custom-made link:
https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email=SomePresetEmail#mail.com
How can I code this to set "SomePresetEmail#mail.com" to be static? Or is that even possible for me to do that, being I am not editing the code on Paypal's server side? My site is currently built using Asp.Net WebForms.
DesignerMind,
I am not sure if I am following you correctly. But this link is displayed on the page to user and you want them to not be able to change the email?
Is it possible to have your link point to an address inside your application that gets redirected to Paypal? When paypal recieves the request, they execute an internal mechanism to hash the request into a secured request variable. This means that when you navigate to the link the user is not seeing the actual link but a hashed version. A sample of the paypal hashed version is.
https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Itqgb8iQ3mW92FT9ldzgcFmJyRVQLUpE2u9UMqeKbGmvwdMTY80oBEmo0SS&dispatch=5885d80a13c0db1f8e263663d3faee8def8934b92a630e40b7fef61ab7e9fe63
Now you could try to do this such as.
On your aspx.net page.
<asp:HyperLink runat="server" ID="paypalLink" NavigateUrl="~/Paypal.aspx" />
or simply
Paypal
And in the Paypal.Aspx code
static string SecretEmail = "someone#somewhere.com",
PaypalRedirectFormat = "https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email={0}";
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect(string.Format(PaypalRedirectFormat, SecretEmail));
}
This is just an idea and actually if this is what you wanted a GenericHandler would do the job quite nicely.
Let me know if this is not what you are looking for.
I have been searching for the most current method for posting a tweet on behalf of a user in Webforms. Most of the information I've come across dates to around 2010 and involves Twitterizer, which is no longer supported by the Twitter API. My question is, is there any updated documentation or examples, tutorials on the subject?
I've created my app, have the consumer key and secret, but most of the code I'm coming across is in php. Any help would be appreciated.
Since you're using WebForms (via your reply in comments), here's an example of tweeting on another user's behalf with LINQ to Twitter. Other examples might show you how to add a signature to an authorization header, but you'll still have to manage the OAuth workflow. This should give you an idea of how that workflow can be managed in WebForms.
LINQ to Twitter uses different authorizers to manage the process of producing OAuth signatures, managing credentials, and supporting OAuth workflow. First, instantiate a WebAuthorizer, like this:
public partial class _Default : System.Web.UI.Page
{
private WebAuthorizer auth;
private TwitterContext twitterCtx;
protected void Page_Load(object sender, EventArgs e)
{
IOAuthCredentials credentials = new SessionStateCredentials();
if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
{
credentials.ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
credentials.ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
}
auth = new WebAuthorizer
{
Credentials = credentials,
PerformRedirect = authUrl => Response.Redirect(authUrl)
};
The WebAuthorizer only needs your ConsumerKey and ConsumerSecret, which can be saved in web.config. The authorization process is divided into two parts because you have to send the user to Twitter to authorize your app and then Twitter redirects the user back to your page to collect the other two tokens, which are oauth_token and access_token. That means you need logic to handle the callback from Twitter, which could look like this:
if (!Page.IsPostBack && Request.QueryString["oauth_token"] != null)
{
auth.CompleteAuthorization(Request.Url);
}
This goes after you instantiate WebAuthorizer and makes sure you're processing a Twitter callback before performing completion. After you call CompleteAuthorize, go into auth.Credentials and grab the new user credentials and save them for the logged in user. On subsequent queries, you can then load all 4 credentials into WebAuthorizer and LINQ to Twitter will work without requiring the user to authorize your application again.
After you have credentials, you can instantiate a TwitterContext, which gives you access to the Twitter API. Here's an example that does that and performs a query:
if (auth.IsAuthorized)
{
twitterCtx = new TwitterContext(auth);
var search =
(from srch in twitterCtx.Search
where srch.Type == SearchType.Search &&
srch.Query == "LINQ to Twitter"
select srch)
.SingleOrDefault();
TwitterListView.DataSource = search.Statuses;
TwitterListView.DataBind();
}
This code follows the call to auth.CompleteAuthorize to make sure all credentials are populated. The auth.IsAuthorized verifies that all 4 credentials are present.
That was the completion and instantiation of the TwitterContext part, but you'll first need to start the oauth process. Here's a button click handler that does that:
protected void authorizeTwitterButton_Click(object sender, EventArgs e)
{
auth.BeginAuthorization(Request.Url);
}
Just call BeginAuthorization, which executes the callback assigned to the PerformRedirect property of WebAuthorizer, sending the user to Twitter to authorize your app. As mentioned earlier, Twitter redirects the user back to your page and CompleteAuthorization executes to finish the authorization process. I typically put the OAuth logic on a separate page to simplify things.
Once the user authorizes your app, you can execute any query you want, such as the method below that tweets some text for the user:
protected void postUpdateButton_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
{
return;
}
twitterCtx.UpdateStatus(updateBox.Text);
updateBox.Text = string.Empty;
}
Tip: the SessionStateCredentials stores credentials in session state. So, you want to make sure you're using state server, SQL server, but definitely not InProc.
There's documentation on the LINQ to Twitter site at CodePlex.com and a working demo in the LinqToTwitterWebFormsDemo in the downloadable source code.
Say I've got a method in c# MVC to send email with ajax, like:
public class mailController : Controller {
SmtpClient mailserver = new SmtpClient("smtp.foo.com");
public string send(string from, string to, string subject = "", string body = "", string cc = "", string bcc = "") {
MailMessage message = new MailMessage(from, to, subject, body);
if (cc.Length > 0) {
message.CC.Add(cc);
}
if (bcc.Length > 0) {
message.Bcc.Add(bcc);
}
mailserver.Send(message);
return "MessageSent";
}
}
Is there anything I can do to make this more secure? I mean, as it stands anyone can type the relevant info into their address bar. http://www.foo.com/mail/send?from=etc If I want to use this for form submission, I can't password protect it, or I'd have to use that in the javascript, which is easy to find. I considered setting a cookie and using that as authentication, but that only goes so far. Is there a standard procedure for protecting ajax methods?
You need to validate on the server that the parameters are what you want them to be.
You need to implement a secure session token, to prevent unauthorized users (those without valid sessions) from being able to send an email. This is basically no different than any other cross site request forgery (CSRF) attack vector. If you need any additional information just Google 'CSRF protection ASP.NET`' or similar to get some more concrete examples of how to do this.
Your requirements sound mutually exclusive.
If you do want to leave it public, but you don't want it abused, then maybe you could provide some sort of throttle where you only allow x number of requests from a specific IP address.
You can also use mailto: in an HTMLform to prompt the client to send the email.
As a start you can always store the IP that accessed your controller, if same IP is trying to send mail in specific frequency that you define you can deside to block it ot whatever...
at second you can generate a random number in your mailing page that will be send to the controller -> this will allow you to verify that the mail is sent from your site and not from third party
I want to create password field in Data Grid view in WinForm c# .NET.
How should i proceed?
If it's for creating a password and you must do it in the grid, just use plain text and clear it out once you create the account.
If you're building an app where a customer service rep builds an account for a user, either send the user a password you generate or use some default password for your company (I would only use this with internal-use-only software). Then force them to change it on the user's first login.
I can only assume you don't want the ability of your grid users to view passwords. If indeed that is the case, don't do it!!!
Try the following code. It may helpful to you.
protected void GridView1_PreRender1(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
string pwd = new string('*', row.Cells[2].Text.Length);
}
}