My problem when I use MySQL server, the calendar was appear but when I change the connection to SQL server the calendar doesn't appear. I have no idea how to solve this problem. Is that anything that I have to change the code to make the calendar appear?
HTML:
<script type="text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to proceed ?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
<script type="text/javascript">
function ConfirmEvent() {
var confirm_value_event = document.createElement("INPUT");
confirm_value_event.type = "hidden";
confirm_value_event.name = "confirm_value_event";
if (confirm("Do you want to proceed ?")) {
confirm_value_event.value = "Yes";
} else {
confirm_value_event.value = "No";
}
document.forms[0].appendChild(confirm_value_event);
}
</script>
<style type="text/css">
.style1 {
font-weight: bold;
width: 120px;
}
.style2 {
color: Blue;
font-weight: bold;
text-decoration: underline;
height: 25px;
}
.style5 {
color: Blue;
font-weight: bold;
text-decoration: underline;
}
.style6 {
width: 96px;
}
.style7 {
width: 150px;
}
</style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<div id='calendar'>
</div>
VB.NET:
Public Class _Default
Inherits System.Web.UI.Page
Public eventstring As String
"server=xxx.xxx.x.x\SQLEXPRESS;database=attendance;uid=ab;pwd=abcde;"
Dim Conn As SqlConnection
Dim da As SqlDataAdapter
Dim cmd As SqlCommand
Dim rdmysql As SqlDataReader
Dim strsql As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim lbl As Label = Master.FindControl("lblHeader")
lbl.Text = "IT Attendance"
Dim startdate As String = Format(Now, "yyyy-MM-dd")
If txtStartDate.Value = "" Then txtStartDate.Value = startdate
If txtEndDate.Value = "" Then txtEndDate.Value = startdate
If txtStartEvent.Value = "" Then txtStartEvent.Value = startdate
If txtEndEvent.Value = "" Then txtEndEvent.Value = startdate
Conn = New SqlConnection
Conn.ConnectionString = ConnStr
Conn.Open()
eventstring = ""
strsql = "SELECT * FROM record;"
cmd = New SqlCommand
cmd.Connection = Conn
cmd.CommandText = strsql
rdmysql = cmd.ExecuteReader
Do While rdmysql.Read = True
eventstring = eventstring & "{title: '" & rdmysql.GetString(1) & " - " & rdmysql.GetString(3) & "', start: '" & rdmysql.GetString(2) & "', color: 'yellow', borderColor: 'black', textColor: 'black'},"
Loop
cmd.Dispose()
rdmysql.Close()
strsql = "SELECT * FROM event;"
cmd = New SqlCommand
cmd.Connection = Conn
cmd.CommandText = strsql
rdmysql = cmd.ExecuteReader
Do While rdmysql.Read = True
eventstring = eventstring & "{title: '" & rdmysql.GetString(1) & "', start: '" & rdmysql.GetString(2) & "', color: 'skyblue', textColor: 'black', borderColor: 'black'},"
Loop
cmd.Dispose()
rdmysql.Close()
eventstring = Mid(eventstring, 1, Len(eventstring) - 1)
Anyone can help me to solve this problem?
I have used VB.net for my project, ticketing system, where you add new ticket it should be sending mail to some Emails I have defined in other class
but I have silly problem, which is sending mail through local host.
is there any suggestion from this source code, when I uploaded to specific domain it works, but for localhost not working with me which that I don't receive any mail when I run my project
I want to send mail from localhost
Private Function SendConfirmationEmail(ByVal EmailAddress As String, ByVal Operation As String, ByVal CorreCode As String, ByVal CorrSubj As String, ByVal CutName As String, ByVal phone As String, ByVal CustomerEmail As String) As Boolean
''''''''''''''''''''''Getting Email Setting Information'''''''''''''''''''''''''''''''''''''''
Try
Dim FromMail As String = System.Configuration.ConfigurationManager.AppSettings.GetValues("DefualtMail")(0).ToString()
Dim PassMail As String = System.Configuration.ConfigurationManager.AppSettings.GetValues("DefualtMailPass")(0).ToString
Dim SenderName As String = "Customer Managment Team"
Dim SMTPHost As String = System.Configuration.ConfigurationManager.AppSettings.GetValues("SMTPHost")(0).ToString
''''''''''''''''''''''''''''''''''''Sending Emails'''''''''''''''''''''''''''''''''''''''''''''''''
Dim Mail As New MailMessage
Dim Body As String = ""
Dim Subject As String = Operation
Dim SendTo As String = EmailAddress
''''''''''''''''''''''''''''''''''E-mail'''''''''''''''''''''''''''''''''''''
If SendTo <> vbNullString Then
Mail.To.Clear()
Mail.CC.Clear()
Mail.Bcc.Clear()
Mail.To.Add(SendTo)
Mail.From = New MailAddress(FromMail, "Ticket Code : " + CorreCode)
Mail.IsBodyHtml = True
Dim reader As StreamReader
reader = New StreamReader(Server.MapPath("Index.html"))
Body = reader.ReadToEnd
Body = Body.Replace("MessageSubject", Operation)
Body = Body.Replace("Description", "description : " + CorrSubj)
Body = Body.Replace("customer_info", "Customer Name : " + CutName)
Body = Body.Replace("phone_number", "Customer Phone : " + phone)
Body = Body.Replace("email_address", "Customer address : " + CustomerEmail)
' Body = Body.Replace("PropertyTitle", "Ticket Code :" + CorreCode + " Ticket Description :" + CorrSubj + " Customer info : " + CutName + " phone number : " + phone + " email_address : " + EmailAddress)
Mail.Body = Body
' "<html dir='ltr'><body><h1>Confirmation</h1><br/> Please confirm you email at this link <br/> <a href='108.60.209.97/enmaa/ConfirmEmail.aspx/Enmaa0000" + ApproveId + "'>Confirm</a></body></html>"
Mail.Subject = Subject
'######################################## Sending The EMail########################################################
Dim SMTP As New SmtpClient(SMTPHost)
SMTP.Credentials = New System.Net.NetworkCredential(FromMail, PassMail)
SMTP.Host = SMTPHost
SMTP.Port = 587 '587
SMTP.EnableSsl = True
SMTP.Send(Mail)
End If
Return True
How do I set the code below to generate email with high priority in the subject line? Thank you for any guidance.
Private Sub SendEmail(ByVal pharmEmail As String, ByVal backupEmail As String)
Dim smtpClient As New System.Net.Mail.SmtpClient()
Dim message As New System.Net.Mail.MailMessage()
Try
Dim fromAddress As New System.Net.Mail.MailAddress(WebConfigurationManager.AppSettings("EmailFromAddr"), WebConfigurationManager.AppSettings("EmailFromName"))
message.From = fromAddress
message.To.Add(pharmEmail)
message.Subject = WebConfigurationManager.AppSettings("EmailSubject")
If (WebConfigurationManager.AppSettings("backupEnabled") = True) Then
message.CC.Add(backupEmail)
End If
message.IsBodyHtml = True
Dim orderURL As New HyperLink
orderURL.Text = "here"
orderURL.NavigateUrl = "http://" & WebConfigurationManager.AppSettings("ServerName") & "/User/ReviewOrder.aspx?orderID=" & webOrderID
message.Body = "An order was created using the account of " + Profile.FirstName.ToString() + " " + Profile.LastName.ToString() + ". " + WebConfigurationManager.AppSettings("EmailBody") + "<a href='" + orderURL.NavigateUrl + "'>here.</a>"
'message.Body = WebConfigurationManager.AppSettings("EmailBody") & " " & orderURL.
smtpClient.Send(message)
Catch ex As Exception
ErrorHandler.WriteError(ex.ToString)
Throw ex
End Try
I believe you can set the Priority property on the MailMessage. See MSDN for more details.
I am trying to send email using ASP.NET through Gmail server. This is my code, can you help me how to resolve the timeout issue.
try
{
MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
mail.IsBodyHtml = true;
mail.Priority = System.Net.Mail.MailPriority.High;
mail.From = new MailAddress("FromEmail#gmail.com");
mail.To.Add("ToEmail#gmail.com");
mail.Subject = "Fees Reminder";
mail.Body = "Please, Student ID: " + username + " pay your fees " + sqlFeesValue + ".";
mail.Body += " <html>";
mail.Body += "<body>";
mail.Body += "<table>";
mail.Body += "<tr>";
mail.Body += "<td>User Name : </td><td>" + username + "</td>";
mail.Body += "</tr>";
mail.Body += "<tr>";
mail.Body += "<td>Fees : </td><td> " + sqlFeesValue.ToString() +"</td>";
mail.Body += "</tr>";
mail.Body += "</table>";
mail.Body += "</body>";
mail.Body += "</html>";
smtp.Port = 465;
smtp.Credentials = new System.Net.NetworkCredential("email#gmail.com", "passwd");
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail);
}
catch (Exception error)
{
lblMessage.Visible = true;
lblMessage.Text = error.Message;
}
Thanks in advance
Try using a different port number.
Gmail will accept port 25 or 587 when sending mail but times out using port 465.
Also make sure you have UseDefaultCredentials = False also.
I am a newcomer in .net , my problem is related to email. This code is well performed on my localhost. This is code of my enquiry.aspx.cs:-
protected void Button1_Click(object sender, EventArgs e)
{
Mail mm = new Mail();
if (DropDownList3.SelectedItem.Text == "--Select--")
{
Label5.Text = "Please Select Course";
//Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('Please Enter Name');", true);
//Response.Write("<script language=JavaScript> alert('Please Enter Name'); </script>");
}
else if (TextBox1.Text == "")
{
Label5.Text = "Please Enter Name";
//Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('Please Enter Name');", true);
//Response.Write("<script language=JavaScript> alert('Please Enter Name'); </script>");
TextBox1.Focus();
}
else if (mm.checkValidemail(TextBox2.Text) == false)
{
Label5.Text = "Please Enter E-Mail ID";
//Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('Please Enter E-Mail ID');", true);
//Response.Write("<script language=JavaScript> alert('Please Enter E-Mail ID'); </script>");
TextBox2.Focus();
}
else if (mm.checkValidmobile(TextBox3.Text) == false)
{
Label5.Text = "Please Enter Mobile Number";
//Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('Please Enter Mobile Number');", true);
//Response.Write("<script language=JavaScript> alert('Please Enter Mobile Number'); </script>");
TextBox3.Focus();
}
else
{
myenquiry ee = new myenquiry();
//myenquiry ee=new myenquiry();
int i = ee.add_enquiry(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, "-", "-", "NORMAL ENQUIRY FROM SITE", TextBox11.Text, DropDownList3.SelectedItem.Text, TextBox12.Text,locationlst.SelectedItem.Text);
if (i == 1)
{
MailMessage message = new MailMessage();
message.From = new MailAddress(" Enquiry " + "<shila#gmail.com> ");
message.To.Add(new MailAddress("shu#gmail.com"));
message.CC.Add(new MailAddress("va_aone#yahoo.com"));
message.Subject = "Enquiry from CMC site";
string p = "<b>Name: </b>" + TextBox1.Text;
p += "<br><b>Mobile:</b> " + TextBox3.Text;
p += "<br><b>Mail ID:</b> " + TextBox2.Text;
p += "<br><b>Address:</b> " + TextBox4.Text;
p += "<br><b>City:</b> " + TextBox5.Text;
p += "<br><b>Location:</b>" + locationlst.SelectedItem.Text;
p += "<br><b>College:</b> " + TextBox11.Text;
p += "<br><b>Course:</b> " + DropDownList3.SelectedItem.Text;
p += "<br><b>Query:</b> " + TextBox12.Text;
message.Body = p;
message.IsBodyHtml = true;
SmtpClient SMTPServer = new SmtpClient("localhost");
try
{
SMTPServer.Send(message);
//result = "Your Enquiry has been Submitted !!";
Label5.Text = "Your Enquiry has been Submitted !!";
//Response.Write("<script language=JavaScript> alert('Your Enquiry has been Submitted !!'); </script>");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox11.Text = "";
TextBox12.Text = "";
DropDownList3.SelectedIndex = 0;
}
catch
{
Label5.Text = "Server Problem !!Your Enquiry Not Submitted";
//Response.Write("<script language=JavaScript> alert('Server Problem !!Your Enquiry Not Submitted'); </script>");
}
}
else
{
Label5.Text = "Server Problem !!Your Enquiry Not Submitted";
}
}
and this is my appcode folder enquiry.cs:-
public class myenquiry
{
SqlConnection conn = new SqlConnection("Data Source=USER-PC;Initial Catalog=group;Integrated Security=True");
SqlCommand comm = new SqlCommand();
int result = 0;
public int add_enquiry(string nam,string email,string mob,string adr,string cit,string state,string country,string zip,string college,string tech,string query,string loc)
{
try
{
comm.Connection = conn;
comm.CommandText = "insert into enquiry(name,email,mobile,address,city,state,country,zip,college,technology,query,edate,location) values('" + nam + "','" + email + "','" + mob + "','" + adr + "','" + cit + "','" + state + "','" + country + "','" + zip + "','" + college + "','" + tech + "','" + query + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','"+loc+"')";
conn.Open();
comm.ExecuteNonQuery();
result = 1;
}
catch(Exception ee)
{
result = 0;
}
finally
{
conn.Close();
}
return result;
}
}
this is well perform on local. But at the server the appcode enquiry.cs is not called on enquiry.aspx.cs and the value of int i is becoming 0, so the else part is executing. Why?
You seem to have a hard coded connection string in the myenquiry class. If you are not dynamically setting the connection string from a configuration file or otherwise, the insert method will try to use that string which points to your local. Assuming your server is a different domain/machine with no access to your local DB, the connection will definitely fail, giving you the result 0.
As Shree.pat18 says Don't make hardcodded connection string in class file.instead of this make your connection string in web.config file something like this in your configuration tag
<connectionStrings>
<add name="cn" connectionString="Data Source=USER-PC;Initial Catalog=group;Integrated Security=True"/>
</connectionStrings>