|
Mostrar Mensajes
|
Páginas: [1] 2 3
|
2
|
Programación / .NET (C#, VB.NET, ASP) / Re: Enviar DataGridView por Email VB.net 2010
|
en: 21 Septiembre 2015, 10:49 am
|
Gracias a sus consejos pude resolver el problema. El código quedo así: Dim html As String = String.Empty Dim html2 As String = String.Empty Dim html3 As String = String.Empty Dim Mail As New MailMessage Mail.Subject = My.Settings.oggetto Mail.To.Add(My.Settings.destinatario) Mail.From = New MailAddress(My.Settings.mittente) Mail.IsBodyHtml = True Dim tipo, nome, tipo_appuntamento, scadenza, note As String Dim strMailBody As String Dim i As Integer html = html & "<B>Buongiorno, " & " <BR> " html = html & "Queste sono le scadenze per i prossimi " & My.Settings.allert & " giorno/i " & " <BR><BR> </B>" html = html & "<TABLE cellpadding=""1"" COLS=""1"" SIZE=""1"" border=""1"" BORDERCOLOR= ""black"">" html3 = html3 & "</FONT></TABLE><BR><BR>" html3 = html3 & "Cordiali saluti" For i = 0 To DataGridView1.Rows.Count - 1 tipo = DataGridView1.Item(0, i).Value.ToString nome = DataGridView1.Item(1, i).Value.ToString tipo_appuntamento = DataGridView1.Item(2, i).Value.ToString scadenza = DataGridView1.Item(3, i).Value.ToString note = DataGridView1.Item(4, i).Value.ToString html2 = html2 & "<TR><TH>" html2 = html2 & tipo & " </TH>" html2 = html2 & "<TH>" html2 = html2 & nome & "</TH>" html2 = html2 & "<TH>" html2 = html2 & tipo_appuntamento & " </TH>" html2 = html2 & "<TH>" html2 = html2 & scadenza & "</TH>" html2 = html2 & "<TH>" html2 = html2 & note & "</TH>" html2 = html2 & "</TR>" Next strMailBody += html & html2 & html3 & vbCrLf Mail.Body = strMailBody Dim SMTP As New SmtpClient(My.Settings.server_email) SMTP.EnableSsl = True SMTP.Credentials = New System.Net.NetworkCredential(My.Settings.utente_email, My.Settings.password_email) SMTP.Port = My.Settings.porta_email SMTP.Send(Mail) MsgBox("Email inviata!")
Muchas gracias!! Saludos!
|
|
|
3
|
Programación / .NET (C#, VB.NET, ASP) / Enviar DataGridView por Email VB.net 2010
|
en: 18 Septiembre 2015, 15:37 pm
|
Hola, Estoy intentando enviar un DataGridView por Email. Mi problema es que el email que recibo repite por cada renglón del datagridview todo el mensaje. Y obviamente lo que yo busco hacer es que envie la tabla completa. Me explico mejor con un ejemplo, lo que recibo es lo siguiente: Buenos dias
nombre apellido Juan Perez
Saludos
Buenos dias
nombre apellido Roberto Diaz
Saludos
Y lo que yo quiero recibir es esto: Buenos dias
nombre apellido Juan Perez Roberto Diaz
Saludos
Este es el codigo que exporta el datagridview y envia el email, por favor alguien me podria decir donde me equivoco? Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Dim html As String = String.Empty Dim Mail As New MailMessage
Mail.Subject = My.Settings.oggetto Mail.To.Add(My.Settings.destinatario) Mail.From = New MailAddress(My.Settings.mittente) Mail.IsBodyHtml = True Dim tipo, nome, tipo_appuntamento, scadenza, note As String Dim strMailBody As String Dim i As Integer
For i = 0 To DataGridView1.Rows.Count - 1
tipo = DataGridView1.Item(0, i).Value.ToString nome = DataGridView1.Item(1, i).Value.ToString tipo_appuntamento = DataGridView1.Item(2, i).Value.ToString scadenza = DataGridView1.Item(3, i).Value.ToString note = DataGridView1.Item(4, i).Value.ToString
html = html & "<HTML>" html = html & "<HEAD>" html = html & "<TITLE>Avvisi Sicurezza</TITLE>" html = html & "</HEAD>" html = html & "<BODY bgcolor=""lightyellow"">" html = html & " " & Now() & " <BR> <BR> " html = html & "<B>Buongiorno, " & DataGridView1.Rows.Count & " <BR> " html = html & "Queste sono le scadenze per i prossimi " & My.Settings.allert & " giorno/i " & " <BR><BR> </B>" html = html & "<TABLE cellpadding=""1"" COLS=""1"" SIZE=""1"" border=""1"" BORDERCOLOR= ""black"">" html = html & "<TR><TH>" html = html & tipo & " </TH>" html = html & "<TH>" html = html & nome & "</TH>" html = html & "<TH>" html = html & tipo_appuntamento & " </TH>" html = html & "<TH>" html = html & scadenza & "</TH>" html = html & "<TH>" html = html & note & "</TH>" html = html & "</TR>" html = html & "</FONT></TABLE><BR>" html = html & "</BODY>" html = html & "</HTML>"
Next
Mail.Body = html
Dim SMTP As New SmtpClient(My.Settings.server_email) SMTP.EnableSsl = True SMTP.Credentials = New System.Net.NetworkCredential(My.Settings.utente_email, My.Settings.password_email) SMTP.Port = My.Settings.porta_email SMTP.Send(Mail) MsgBox("Email inviata!") End Sub
Gracias! Saludos!
|
|
|
5
|
Programación / .NET (C#, VB.NET, ASP) / Re: VB.NET 2010 Download de archivos binarios en DataGridView desde MySQL
|
en: 23 Agosto 2015, 22:39 pm
|
Aquí la solución por si a alguien mas puede ser de ayuda: Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
Dim conn As New MySqlConnection Dim cmd As New MySqlCommand Dim myData As MySqlDataReader Dim SQL As String Dim rawData() As Byte Dim FileSize As UInt32 Dim fs As FileStream
conn.ConnectionString = "Server=8.8.8.8;User Id=xxx;Password=xxxx;Database=sicurezza"
SQL = "select allegato, file_size, nome_file from dipendenti_allegati where nome_file=" _ & """Licenze Kaspersky 2014.pdf"""
Try conn.Open()
cmd.Connection = conn cmd.CommandText = SQL
myData = cmd.ExecuteReader
If Not myData.HasRows Then Throw New Exception("There are no BLOBs to save")
myData.Read()
FileSize = myData.GetUInt32(myData.GetOrdinal("file_size")) rawData = New Byte(FileSize) {}
myData.GetBytes(myData.GetOrdinal("allegato"), 0, rawData, 0, FileSize)
fs = New FileStream("C:\Users\yo\Desktop\" & myData.GetString(myData.GetOrdinal("nome_file")), FileMode.OpenOrCreate, FileAccess.Write) fs.Write(rawData, 0, FileSize) fs.Close()
MessageBox.Show("Archivo guardado!", "OK!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
myData.Close() conn.Close() Catch ex As Exception MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try
End Sub
Saludos!
|
|
|
6
|
Programación / .NET (C#, VB.NET, ASP) / VB.NET 2010 Download de archivos binarios en DataGridView desde MySQL
|
en: 23 Agosto 2015, 14:15 pm
|
Hola! Tengo un DataGridView en el que elenco una serie de archivos binarios (PDF), que se encuentran guardados en una tabla de un database MySQL. Las columnas de la tabla son las siguientes (El archivo binario se encuentra en la columna allegato): matricola int(11) matricola_old int(11) nome_file text file_size decimal(20,0) allegato longblob extension text data text Mi problema es que no se como hacer para descargar estos archivos, intente hacer que una de las columnas tenga la propiedad DataGridViewLinkColumn, o bien agregar otra columna con un button pero la verdad es que me estoy perdiendo... Este es el codigo que uso, donde carga los archivos binarios: Dim Query As New MySqlCommand Dim Conexion As MySqlConnection Dim Consultar As MySqlDataReader Dim Sql As String = "Server=172.XX.XX.XX;User Id=XXX;Password=XXX;Database=sicurezza" Dim query_Adapter2 As String If ComboBox7.Text = "matricola_old" Then
query_Adapter2 = "SELECT dipendenti_allegati.nome_file, dipendenti_allegati.data, dipendenti_allegati.allegato As Allegato FROM dipendenti_allegati INNER JOIN dipendenti ON dipendenti_allegati.matricola = dipendenti.matricola WHERE dipendenti." & ComboBox7.Text & " = " & TextBox17.Text & "" Else query_Adapter2 = "SELECT dipendenti_allegati.nome_file, dipendenti_allegati.data, dipendenti_allegati.allegato As Allegato FROM dipendenti_allegati INNER JOIN dipendenti ON dipendenti_allegati.matricola = dipendenti.matricola WHERE dipendenti." & ComboBox7.Text & " LIKE '%" & TextBox17.Text & "%'" End If
Conexion = New MySqlConnection() Conexion.ConnectionString = Sql Conexion.Open() Query.CommandText = query_Adapter2 Query.Connection = Conexion Consultar = Query.ExecuteReader While Consultar.Read
Dim File As String = Consultar(0).ToString Dim Data As String = Consultar(1).ToString Dim texto As String = Consultar(2).ToString Dim Allegato As String = Consultar(3).ToString DataGridView4.Rows.Add(File, texto, Data, Allegato) DataGridView4.Refresh() End While
Por favor alguien me podría ayudar o darme alguna sugerencia? Gracias Saludos!
|
|
|
7
|
Programación / .NET (C#, VB.NET, ASP) / Re: Ciclo For en ListBox
|
en: 9 Agosto 2015, 14:50 pm
|
Gracias! al final lo solucione guardando a medida que paso los items de un listbox al otro (como tu primer sugerencia) y bueno hago lo mismo, pero con una query de DELETE, cuando paso el Item del listbox2 al 1. Gracias! Saludos
|
|
|
8
|
Programación / .NET (C#, VB.NET, ASP) / Ciclo For en ListBox
|
en: 8 Agosto 2015, 17:29 pm
|
Hola, Tengo dos listbox, donde desde el listbox1 paso al listbox2 algunos Items. Una vez que paso estos Items tengo que guardarlos (desde el ListBox2 al database). Mi problema es que tendría que salvar en el database solo los items que voy agregando... Actualmente lo que hace es salvar todos los Items que me muestra el listbox2, entonces es como que si duplicase todo lo que guardo en el database. Dim i As Integer
For i = 0 To ListBox2.Items.Count()
Try ds = New DataSet adapter = New MySqlDataAdapter("INSERT INTO assegnazione_dpi (matricola, matricola_old, nome, cognome, tipo_rischio, attrezzature) VALUES " _ & "('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & ComboBox6.Text & "','" & ListBox2.Items(i) & "')" & Environment.NewLine, conn) adapter.Fill(ds, "assegnazione_dpi") Catch ex As Exception MsgBox(ex.Message) End Try Next
Por favor alguien me podría dar alguna sugerencia para resolver el problema? Gracias Saludos
|
|
|
9
|
Programación / .NET (C#, VB.NET, ASP) / API Google Calendar v3 y VB.NET
|
en: 4 Agosto 2015, 18:38 pm
|
Hola! Estoy intentando utilizar las API de Google Calendar y la verdad es que estoy teniendo algunos problemas... Ya active las API desde la console de Google Developer. El problema es que no encontre ningun ejemplo para VB.net, lo poco que encontre usan las API v2 y ya estas dejaron de funcionar ... Alguien me podria dar alguna indicacion o mostrar un ejemplo? Gracias Saludos
|
|
|
|
|
|
|