U
user12345jmnm
Guest
I have a requirement of reading outlook emails and pushing that data into MySQL database.
My mail looks like this:
SLA warning for INC1234567 Ticket Details: Short description: ship-to 1137..... Caller: Octavian Sam Priority: 3 - Moderate Business service: Lmkp
I have created a table using Maria db in mysql workbench.
I have created a connection from visual studio to mysql.
My code till now is:
String connectingstring = "Server=localhost;Port=3306;UID=root;PWD=*******;Database=emaildatabase;Allow Zero Datetime=True";
MySqlConnection connection = null;
using (connection = new MySqlConnection(connectingstring))
{
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
try
{
string colName = "TicketID, Caller, Priority, BuisnessService";
string paramName = "@TicketID, @Caller, @Priority, @BuisnessService";
string tableName = "emailtable";
MySqlCommand com = new MySqlCommand("insert into " + tableName + " (" + colName + ") values (" + paramName + ")", connection);
MySqlDataReader read = null;
com.Parameters.Clear();
foreach (var dr in **?** )
{
com.Parameters.Add("@TicketID", MySqlDbType.VarChar).Value = dr.ItemArray[0].ToString();
read = com.ExecuteReader();
read.Close();
}
foreach (var dr in )
{
com.Parameters.Add("@Caller", MySqlDbType.VarChar).Value = dr.ItemArray[1].ToString();
read = com.ExecuteReader();
read.Close();
}
foreach ()
{
com.Parameters.Add("@Priority", MySqlDbType.VarChar).Value = dr.ItemArray[2].ToString();
read = com.ExecuteReader();
read.Close();
}
foreach ()
{
com.Parameters.Add("@BuisnessService", MySqlDbType.VarChar).Value = dr.ItemArray[3].ToString();
read = com.ExecuteReader();
read.Close();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
connection.Close();
}
I have a problem going about what i need to enter in foreach such that values can be entered into database when i execute this code.
Thank you.
Continue reading...
My mail looks like this:
SLA warning for INC1234567 Ticket Details: Short description: ship-to 1137..... Caller: Octavian Sam Priority: 3 - Moderate Business service: Lmkp
I have created a table using Maria db in mysql workbench.
I have created a connection from visual studio to mysql.
My code till now is:
String connectingstring = "Server=localhost;Port=3306;UID=root;PWD=*******;Database=emaildatabase;Allow Zero Datetime=True";
MySqlConnection connection = null;
using (connection = new MySqlConnection(connectingstring))
{
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
try
{
string colName = "TicketID, Caller, Priority, BuisnessService";
string paramName = "@TicketID, @Caller, @Priority, @BuisnessService";
string tableName = "emailtable";
MySqlCommand com = new MySqlCommand("insert into " + tableName + " (" + colName + ") values (" + paramName + ")", connection);
MySqlDataReader read = null;
com.Parameters.Clear();
foreach (var dr in **?** )
{
com.Parameters.Add("@TicketID", MySqlDbType.VarChar).Value = dr.ItemArray[0].ToString();
read = com.ExecuteReader();
read.Close();
}
foreach (var dr in )
{
com.Parameters.Add("@Caller", MySqlDbType.VarChar).Value = dr.ItemArray[1].ToString();
read = com.ExecuteReader();
read.Close();
}
foreach ()
{
com.Parameters.Add("@Priority", MySqlDbType.VarChar).Value = dr.ItemArray[2].ToString();
read = com.ExecuteReader();
read.Close();
}
foreach ()
{
com.Parameters.Add("@BuisnessService", MySqlDbType.VarChar).Value = dr.ItemArray[3].ToString();
read = com.ExecuteReader();
read.Close();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
connection.Close();
}
I have a problem going about what i need to enter in foreach such that values can be entered into database when i execute this code.
Thank you.
Continue reading...