Im tyring to send an email with my program to an gmx email. Every time I try to send the mail I get the same error message in my console.
What can be the solution for that?
The error message:
System.Net.Mail.SmtpException: SMTP server requiers secure connection or the client wasnt authenticated. server response was: authentication required.
in - System.Net.Mail.SendMailAsyncResult.End(IAsyncResult result)
in - System.Net.Mail.SmtpClient.SendMailCallback(IAsyncResult result)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Threading;
using System.ComponentModel;
namespace SMTP_Client
{
class Program
{
static bool mailSent = false;
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
// Get the unique identifier for this asynchronous operation.
String token = (string)e.UserState;
if (e.Cancelled)
{
Console.WriteLine("[{0}] Send canceled.", token);
}
if (e.Error != null)
{
Console.WriteLine("[{0}] {1}", token, e.Error.ToString());
}
else
{
Console.WriteLine("Message sent.");
}
mailSent = true;
}
public static void Main(string[] args)
{
SmtpClient client = new SmtpClient("smtp.gmx.com",25);
MailAddress from = new MailAddress("example#project.com", "me " + (char)0xD8 + " you", System.Text.Encoding.UTF8);
MailAddress to = new MailAddress("example#gmx.com");
MailMessage message = new MailMessage(from, to);
message.Body = "The project has succeeded ";
message.Subject = "made it!";
client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userState = "test message2\n";
client.SendAsync(message, userState);
Console.WriteLine("Sending message... press c to cancel mail. Press any other key to exit.");
string answer = Console.ReadLine();
if (answer.StartsWith("c") && mailSent == false)
{
client.SendAsyncCancel();
}
message.Dispose();
Console.WriteLine("proccess ended.");
}
}
}
Related
I was trying to salt password in asp.net web application mysql but its shows this error.While running getting the error.Please anyone tell me the error?
Error:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'DemoPage.Default'.
Source Error:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DemoPage.Default" %>
Line 2:
Line 3: <!DOCTYPE html>
Source File: /Default.aspx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0
Code default.aspx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebPage1
{
public partial class _default : System.Web.UI.Page
{
MySql.Data.MySqlClient.MySqlConnection conn;
MySql.Data.MySqlClient.MySqlCommand cmd;
MySql.Data.MySqlClient.MySqlDataReader reader;
String queryStr;
String name;
protected void Page_Load(object sender, EventArgs e)
{
DoSQLQuery();
}
protected void submit_click(object sender, EventArgs e)
{
String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
conn.Open();
String queryStr = "";
cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT * FROM webapp.userregistration WHERE username = #name and password=#pas", conn);
cmd.Parameters.AddWithValue("#name", usernameTextBox.Text);
cmd.Parameters.AddWithValue("#pas", passwordTextBox.Text);
reader = cmd.ExecuteReader();
name = "";
while (reader.HasRows && reader.Read())
{
{
name = reader.GetString(reader.GetOrdinal("username")) + " " + reader.GetString(reader.GetOrdinal("password"));
}
//if the data matches the rows (username, password), then you enter to the page
if (reader.HasRows)
{
Session["uname"] = name;
Response.BufferOutput = true;
Response.Redirect("login.aspx", false);
}
else
{
passwordTextBox.Text = "invalid user";
}
}
reader.Close();
conn.Close();
}
private void DoSQLQuery()
{
try
{
}
catch (Exception e)
{
passwordTextBox.Text = e.ToString();
}
}
}
}
I'm trying to call a method on a custom api controller on my azure mobile services client.
If I hit the path in the browser it returns data just fine. When trying to call it from my app I get the following error
"Newtonsoft.Json.JsonReaderException: Error reading string. Unexpected token: StartObject. Path '', line 1, position 1."
public async Task<string> AuthUser (string email, string pass)
{
var id = await client.InvokeApiAsync<string>(
"Login/AuthUser",
System.Net.Http.HttpMethod.Get,
new Dictionary<string, string>() {
{"emailAddress", email },
{"password",pass }
}
);
if (id != null)
{
return id.ToString();
}
else
{
return "";
}
}
Here's the controller I'm calling
using System.Linq;
using System.Web.Http;
using System.Web.Http.Description;
using MyAppService.DataObjects;
using MyAppService.Models;
using Microsoft.Azure.Mobile.Server.Config;
namespace MyAppService.Controllers
{
[MobileAppController]
public class LoginController : ApiController
{
private MyAppContext db = new MyAppContext ();
[HttpGet]
[ActionName("AuthUser")]
public IHttpActionResult Login(string emailAddress, string password)
{
var login = db.Members.FirstOrDefault(m => m.Email == emailAddress && m.Password == password);
if (login != null)
{
return Ok(new {Id = login.Id });
}
else
{
return Unauthorized();
}
}
}
}
EDIT: The issue was the return type from the controller. Changed it to string and it worked.
The issue was the return type from the controller. Changed it to string and it worked
I've finished a Unity game which i want to publish in Google Play, Windows Phone Store and Windows 8 Store. I'm using the very last version of Parse for Unity SDK (1.4.1) and also the last version of Unity Editor (4.6.4p4), including last patches.
The Parse implementation i made in my game works perfectly on:
- Unity Editor (all platforms)
- Android (deploying apk on two devices)
- Android (Publishing the game as alpha, installing it in +8 devices)
- Windows Phone 8 (All Windows Phone Emulators - 8.0 and 8.1 - x86)
- Windows Phone 8 (debugging on device with both Visual Studio 2012 for Windows Phone and Visual Studio 2013 Community - ARM)
It does'nt work on:
- Windows Phone 8 (deploying as a Beta)
- Windows Phone 8 (deploying as Hidden release)
The game crashes every time i try to use any function of the Parse SDK, throws no exception, the Windows Phone 8 Store gives me no info about any crashes... seems like an assembly load issue...
I've no idea what is happening, this issue is stoping me to publishing my game, think i'm going crazy...
So, i've made a simple dummy app to test my parse implementation, and... it has the same issue... it's very simple: Only a gameobject which has the "Parse Initialize Behaviour" attached (with both AppId and .NET keys setted) and a very simple script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.IO;
using System.Text;
using System;
using System.Linq;
using Parse;
using System.Threading.Tasks;
// Demo application script
public class AppScript : MonoBehaviour
{
public static string userName = "Caldofran";
public static string userPass = "Password5";
public static string userEmail = "caldofran#email.com";
public static string errAsincrono = "";
public static string log = "";
public static bool bLogin = false;
public static bool bSignUp = false;
// Use this for initialization
void Start () {
//Application.runInBackground = true;
}
GUIStyle ts = new GUIStyle();
void OnGUI()
{
if (GUI.Button(new Rect(10, 100, 100, 30), "Sign Up"))
SignUp(userName,userPass, userEmail);
if (GUI.Button(new Rect(10, 150, 100, 30), "Login"))
Login(userName, userPass);
if (GUI.Button(new Rect(10, 200, 100, 30), "Logout"))
Logout();
if (GUI.Button(new Rect(10, 300, 100, 30), "Clear Texts"))
{
errAsincrono = "";
log = "";
}
int left = Screen.width - 110;
string usrParse = "";
if (AppScript.IsLoggedInParse())
usrParse = ParseUser.CurrentUser.Username;
ts.normal.textColor = Color.red;
GUI.BeginGroup(new Rect(300, 5, 600, 500));
GUI.Box(new Rect(0, 0, 400, 300), "");
//GUILayout.Label("P: " + mensajeGUI);
GUILayout.Label("User Config: " + userName, ts);
GUILayout.Label("Pass config: " + userPass, ts);
GUILayout.Label("email config: " + userEmail, ts);
GUILayout.Label("Logged in parse: " + AppScript.IsLoggedInParse().ToString(), ts);
GUILayout.Label("Parse logged user: " + usrParse, ts);
GUILayout.Label("Last msg: " + errAsincrono, ts);
GUILayout.Label("Last Log: " + log, ts);
GUI.EndGroup();
}
// Update is called once per frame
void Update () {
if (bLogin)
{
bLogin = false;
log += " Login Update text";
}
if (bSignUp)
{
bSignUp = false;
log += " SignUp Update text";
}
}
#region Parse
public static bool IsLoggedInParse()
{
bool retorno = false;
if ((ParseUser.CurrentUser != null) && (ParseUser.CurrentUser.IsAuthenticated))
retorno = true;
return retorno;
}
public static void SignUp(string userName, string passWord, string email)
{
var user = new ParseUser()
{
Username = userName,
Password = passWord
};
if (string.IsNullOrEmpty(email))
user.Email = "";
else
user.Email = email;
try
{
Task signUpTask = user.SignUpAsync().ContinueWith(t=>
{
if (t.IsFaulted || t.IsCanceled)
{
// The login failed. Check the error to see why.
foreach(var e in t.Exception.InnerExceptions) {
ParseException parseException = (ParseException) e;
log += parseException.Message + ": CODE: " + parseException.Code.ToString();
}
errAsincrono = t.Exception.Message;
}
else
{
// Signup was successful.
log = "Welcome " + userName;
bSignUp = true;
}
});
}
catch (Exception ex)
{
errAsincrono = "Error: " + ex.Message;
}
}
public static void Login(string user, string pass)
{
try
{
ParseUser.LogInAsync(user, pass).ContinueWith(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
// The login failed. Check the error to see why.
foreach(var e in t.Exception.InnerExceptions) {
ParseException parseException = (ParseException) e;
log += parseException.Message + ": CODE: " + parseException.Code.ToString();
}
errAsincrono = t.Exception.Message;
}
else
{
// Login was successful.
log = "Welcome back " + userName;
AppScript.bLogin = true;
}
});
}
catch (Exception ex)
{
errAsincrono = "Error: " + ex.Message;
}
}
public static void ResetPassword(string email)
{
if (IsLoggedInParse())
{
Task requestPasswordTask = ParseUser.RequestPasswordResetAsync(email);
log = "Pass reset ok";
}
}
public static void Logout()
{
if (IsLoggedInParse())
{
ParseUser.LogOutAsync();
log = "Logged out ";
}
}
#endregion
}
Can anybody try it? What i'm doing wrong? Why this code works nearly always but not in Windows Phone (published on the store)?
I've read about Unity bug, which affects only to iOS: http://forum.unity3d.com/threads/unity-5-parse-ios-nsurlerrordomain-error-1012.308569/
This bug (consuming WWW trough SSL) affects Windows Phone apps?
In my case, using Parse SDK 1.6.1 for Windows.
To set Password property throws ArgumentException.
The cause was in Master build configuration and .NET Native tool chain.
Solution 1:
Uncheck "Compile with .NET Native tool chain" in Project's Build settings.
Solution 2:
Create subclass of ParseUser and define "new" properties Username and Password.
Im developing a small Tcp Client Socket application in windows phone. Actually i have a text box, in that whatever the data received from a TCP server, should update continuously in UI text box control.
while (val)
{
result = Receive();
Dispatcher.BeginInvoke((Action)(() =>
{
txtOutput.Text += result;
}));
}
Here in above code, method receive() will receive string data and should update in textbox control but it is not happening,no data is updating to it.
Can any one suggest, how can i resolve this.
Just telling you what i have been advised, "avoid Dispatcher, CoreDispatcher, etc. There are always better solutions."
Below is the piece of code worked for me for both wp8 and wp8.1 WinRT app,
IProgress<object> progress = new Progress<object>(_ => UpdateTicker());
Task.Run(async () =>
{
while (val)
{
progress.Report(null);
}
});
where UpdateTicker() method contains your instructions, in this case...
public void UpdateTicker()
{
result = Receive();
txtOutput.Text += result;
}
Hope this helps...
Thanks for everyone, who given a valuable response for my post.
Hi Nishchith,
I tried your code, but it dint works for me
Here is my logic used to update textbox continuously with data received from TCP server.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PhoneApp3.Resources;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using Windows.Phone.Networking;
using System.Threading.Tasks;
namespace PhoneApp3
{
public partial class MainPage : PhoneApplicationPage
{
Socket _socket = null;
static ManualResetEvent _clientDone = new ManualResetEvent(false);
const int TIMEOUT_MILLISECONDS = 1000;
const int MAX_BUFFER_SIZE = 2048;
const int ECHO_PORT = 9055; // The Echo protocol uses port 7 in this sample
const int QOTD_PORT = 49152; // The Quote of the Day (QOTD) protocol uses port 17 in this sample
string result = string.Empty;
public MainPage()
{
InitializeComponent();
}
private void btnEcho_Click(object sender, RoutedEventArgs e)
{
SocketClient client = new SocketClient();
Connect(txtRemoteHost.Text, ECHO_PORT);
//close();
}
public void Connect(string hostName, int portNumber)
{
DnsEndPoint hostEntry = new DnsEndPoint(hostName, portNumber);
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = hostEntry;
socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e)
{
result = e.SocketError.ToString();
_clientDone.Set();
});
_clientDone.Reset();
Thread.Sleep(2000);
_socket.ConnectAsync(socketEventArg);
Thread.Sleep(5000);
_clientDone.WaitOne(TIMEOUT_MILLISECONDS);
bool val;
if (result == "Success")
{
val = true;
}
else
{
val = false;
}
IProgress<object> progress = new Progress<object>(_ => UpdateTicker());
Task.Run(async () =>
{
while (val)
{
progress.Report(null);
}
});
}
public void UpdateTicker()
{
result = Receive();
string[] strsplit = result.Split(' ');
txtOutput.Text = strsplit[1];
}
public string Receive()
{
string response = "Operation Timeout";
if (_socket != null)
{
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = _socket.RemoteEndPoint;
socketEventArg.SetBuffer(new Byte[MAX_BUFFER_SIZE], 0, MAX_BUFFER_SIZE);
socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e)
{
if (e.SocketError == SocketError.Success)
{
// Retrieve the data from the buffer
response = Encoding.UTF8.GetString(e.Buffer, e.Offset, e.BytesTransferred);
response = response.Trim('\0');
}
else
{
response = e.SocketError.ToString();
}
_clientDone.Set();
});
_clientDone.Reset();
Thread.Sleep(1000);
_socket.ReceiveAsync(socketEventArg);
Thread.Sleep(1000);
_clientDone.WaitOne(TIMEOUT_MILLISECONDS);
}
else
{
response = "Socket is not initialized";
}
return response;
}
public void Close()
{
if (_socket != null)
{
_socket.Close();
}
}
}
}
I am developing a windows phone 8 application to access sky drive. I am getting following error when I call LoginAsync() method-
An exception of type 'Microsoft.Live.LiveAuthException' occurred in mscorlib.ni.dll but was not handled in user code
using System;
using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Live;
namespace SkyDriveApp
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
LiveConnectClient client;
public MainPage()
{
InitializeComponent();
}
public async void Auth()
{
string clientId = "My_client_id";
LiveAuthClient auth = new LiveAuthClient(clientId);
// var result = await auth.InitializeAsync(new[] { "wl.basic", "wl.signin", "wl.skydrive_update" });
var result = await auth.LoginAsync(new[] { "wl.basic", "wl.signin", "wl.skydrive_update" });
if (result.Status == LiveConnectSessionStatus.Connected)
{
client = new LiveConnectClient(result.Session);
tbMessage.Text = "Connected!";
}
}
private void btnLogin_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
{
Auth();
}
}
}
I see that you are using provided login buton, try this:
In xaml:
<live:SignInButton Name="skyBtn" ClientId="your client ID" Scopes="wl.signin wl.skydrive wl.skydrive_update" Branding="Skydrive" TextType="Login"/>
In code behind:
private void skyBtn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
{
if (e.Status == LiveConnectSessionStatus.Connected)
{
session = e.Session;
client = new LiveConnectClient(session);
tbMessage.Text = "Connected!";
}
else tbMessage.Text = "Not Connected!";
if (e.Error != null)
{
tbMessage.Text = "Not Connected!";
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(e.Error.Message);
});
}
}