correo

11/01/2005 - 22:45 por luis tirado | Informe spam
hola grupo

quisiera mandar un correo a travez de mi aplicacion y no
logro conceguirlo qui esta el codigo y el error que sale

'los espacios de nombres a utilizar
Imports System.Web.Mail
Imports System.Web.Mail.MailMessage
Imports System.Web.Mail.SmtpMail



Dim myMail As New MailMessage()
myMail.From = "from@microsoft.com"
myMail.To = "xinpis@hotmail.com"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 -
success</body></html>"

Dim myAttachment As New MailAttachment("c:\luis.txt",
MailEncoding.Base64)
myMail.Attachments.Add(myAttachment)
SmtpMail.SmtpServer = "MyMailServer"
SmtpMail.Send(myMail)



me devuelve un error al ejecutar la aplicacion ::
could not acces 'CDO.Message' Object
si alqguien sabe como hacerlo bien por favor respondame

Preguntas similare

Leer las respuestas

#1 Angel. E. Ruiz. Pastor
12/01/2005 - 03:51 | Informe spam
Prueba con

SmtpMail.SmtpServer = "mail.cantv.net"



Saludos cordiales,

Ángel Ruiz

MCP C#

MVP de Visual Basic desde 2004

Caracas - Venezuela

"El conocimiento es un bien, que crece a medida que se comparte"

"luis tirado" wrote in message
news:1cb101c4f826$e6a05750$
hola grupo

quisiera mandar un correo a travez de mi aplicacion y no
logro conceguirlo qui esta el codigo y el error que sale

'los espacios de nombres a utilizar
Imports System.Web.Mail
Imports System.Web.Mail.MailMessage
Imports System.Web.Mail.SmtpMail



Dim myMail As New MailMessage()
myMail.From = ""
myMail.To = ""
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 -
success</body></html>"

Dim myAttachment As New MailAttachment("c:\luis.txt",
MailEncoding.Base64)
myMail.Attachments.Add(myAttachment)
SmtpMail.SmtpServer = "MyMailServer"
SmtpMail.Send(myMail)



me devuelve un error al ejecutar la aplicacion ::
could not acces 'CDO.Message' Object
si alqguien sabe como hacerlo bien por favor respondame
Respuesta Responder a este mensaje
#2 Mr.Pollosino
13/01/2005 - 16:19 | Informe spam
Bajate los 101 ejemplos de .nte ahi viene un ejemplo muy claro.
El siguiente codigo lo tengo en el evento load del formulario

' Se aegura que el servivio SMTP esté instalado.
Dim services() As ServiceController = ServiceController.GetServices
Dim service As ServiceController
Dim blnHasSmtpService As Boolean = False
Dim strSQL As String
Dim dbCommand As SqlClient.SqlCommand
Dim drSQL As SqlClient.SqlDataReader

' Loop atrevés de todos los serviviosen la maquina y encuentra el
servicio SMTP .
For Each service In services
If service.ServiceName.ToLower = "smtpsvc" Then
blnHasSmtpService = True
Exit For
End If
Next

If Not blnHasSmtpService Then
MessageBox.Show("You do not have SMTP Service installed on this
" & _
"machine. Please check the Readme file for information on
how " & _
"to install SMTP Service.", Me.Text, _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If

' Se asegura que el servico SMTP esté corriendo. si no , lo inicia.
If Not service.Status = ServiceControllerStatus.Running Then
Dim frmStatusMessage As New frmStatus
frmStatusMessage.Show("SMTP Service not currently running. " & _
"Starting service...")
Try
service.Start()
frmStatusMessage.Close()
Catch
MessageBox.Show("There was an error when attempting " & _
"to start SMTP Service. Please consult the Readme " & _
"file for more information.", Me.Text, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If

' Llena el Combo Priority con los valores MailPriority
With cboPriority
.Items.AddRange(New String() {"Normal", "Low", "High"})
.SelectedIndex = 0
End With

'Obteniendo la dirección electrónica destino
txtTo.Text = strEmail

'Obteniendo la dirección electrónica origen
ArchivoDatos = "TesaApps"
Try
conectar(strServidor, ArchivoDatos, strUserID, strPassword)


' Construye el Select para la tabla
strSQL = "SELECT * FROM usuario_notificacion"

dbCommand = New SqlCommand(strSQL, cxn)
drSQL = dbCommand.ExecuteReader()
''Poniendo la bandera en true para cerrar drSQL en la funcion
desconectar
If drSQL.Read Then
txtFrom.Text = Trim(drSQL.Item("email").ToString())
txtCC.Text = drSQL.Item("email").ToString()
strIP = Trim(drSQL.Item("ip").ToString())
End If


'If drSQL.Read() Then
' txtFrom.Text = drSQL.Item("ID_Usuario").ToString()
'End If
'**********************************
'cargando el archivo adjunto
Dim strFile As String
strFile = "C:\Notificar\Notificacion.pdf"

lstAttachments.Items.Add(GetFileName(strFile))

'**********************************
dbCommand.Dispose()
desconectar()
Catch Exp As SqlException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "SQL Error")

Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try

el siguiente codigo esta en el boton enviar:
'******************************
'cargando el archivo adjunto
Dim strFile As String
strFile = "C:\Notificar\Notificacion.pdf"
' GetFileName(strFile)
If IsNothing(arlAttachments) Then
arlAttachments = New ArrayList

' Clear the "(No Attachments)" default text in the ListView
lstAttachments.Items.Clear()
End If
arlAttachments.Add(New MailAttachment(strFile))
lstAttachments.Items.Add(GetFileName(strFile))
' Perform validation on the To and From email address fields, which
are
' both required for sending an email.
If lstAttachments.Items.Count = 0 Then
MsgBox("Falta adjuntar el archivo.")
Exit Sub
End If
Try
ValidateEmailAddress(txtFrom)
Catch ex As Exception
txtFrom.Select(0, txtFrom.Text.Length)

' Set the ErrorProvider error with the text to display.
erpEmailAddresses.SetError(txtFrom, ex.Message)
Exit Sub
End Try

Try
ValidateEmailAddress(txtTo)
Catch exp As Exception
txtTo.Select(0, txtTo.Text.Length)

' Set the ErrorProvider error with the text to display.
erpEmailAddresses.SetError(txtTo, exp.Message)
Exit Sub
End Try

' Use the StringBuilder class instead of traditional string
concatenation.
' It is optimized for building strings because it is capable of
modifying
' the underlying buffer instead of having to make a copy of the
string for
' each concatenation. Consult the SDK documentation for more
information on
' this new class.
Dim sb As New StringBuilder

' Build the email message body.
sb.Append("Este E-Mail fue enviado por un sistema automatizado,
cualquier aclaración favor de comunicarse al teléfono: (01 33) 3540-5400,
ext. 1112. ")
sb.Append(vbCrLf)
sb.Append(vbCrLf)
' sb.Append("SUBJECT: ")
sb.Append(Trim(txtSubject.Text))
sb.Append(vbCrLf)
sb.Append(vbCrLf)
' sb.Append("MESSAGE: ")
sb.Append(Trim(txtBody.Text))
sb.Append(vbCrLf)

' Creating a mail message is as simple as instantiating a class and
' setting a few properties.
Dim mailMsg As New MailMessage
With mailMsg
.From = txtFrom.Text.Trim
.To = txtTo.Text.Trim
.Cc = txtCC.Text.Trim
' .Bcc = txtBCC.Text.Trim
.Subject = txtSubject.Text.Trim
.Body = sb.ToString
.Priority = CType(cboPriority.SelectedIndex, MailPriority)

If Not IsNothing(arlAttachments) Then
Dim mailAttachment As Object
For Each mailAttachment In arlAttachments
.Attachments.Add(mailAttachment)
Next
End If
End With

' Set the SmtpServer name. This can be any of the following
depending on
' your local security settings:

' a) Local IP Address (assuming your local machine's SMTP server has
the
' right to send messages through a local firewall (if present).

' b) 127.0.0.1 the loopback of the local machine.

' c) "smarthost" or the name or the IP address of the exchange
server you
' utilize for messaging. This is usually what is needed if you are
behind
' a corporate firewall.

' See the Readme file for more information.
' SmtpMail.SmtpServer = "smarthost" strIP
' SmtpMail.SmtpServer = "192.168.1.3"
SmtpMail.SmtpServer = strIP
' Use structured error handling to attempt to send the email message
and
' provide feedback to the user about the success or failure of their
' attempt. lstAttachments
Try
SmtpMail.Send(mailMsg)
lstAttachments.Items.Clear()
' lstAttachments.Items.Add("(No Attachments)")

MessageBox.Show("Tu correo ha sido enviado exitosamente!", _
"Estatus de envio", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Catch exp As Exception
MessageBox.Show("El siguiente problema ocurrió cuando intentaba
" & _
"enviar tu E-Mail: " & exp.Message, _
Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Espero que te sirva de algo.
"Angel. E. Ruiz. Pastor" wrote:

Prueba con

SmtpMail.SmtpServer = "mail.cantv.net"



Saludos cordiales,

Ángel Ruiz

MCP C#

MVP de Visual Basic desde 2004

Caracas - Venezuela

"El conocimiento es un bien, que crece a medida que se comparte"

"luis tirado" wrote in message
news:1cb101c4f826$e6a05750$
> hola grupo
>
> quisiera mandar un correo a travez de mi aplicacion y no
> logro conceguirlo qui esta el codigo y el error que sale
>
> 'los espacios de nombres a utilizar
> Imports System.Web.Mail
> Imports System.Web.Mail.MailMessage
> Imports System.Web.Mail.SmtpMail
>
>
>
> Dim myMail As New MailMessage()
> myMail.From = ""
> myMail.To = ""
> myMail.Subject = "UtilMailMessage001"
> myMail.Priority = MailPriority.Low
> myMail.BodyFormat = MailFormat.Html
> myMail.Body = "<html><body>UtilMailMessage001 -
> success</body></html>"
>
> Dim myAttachment As New MailAttachment("c:\luis.txt",
> MailEncoding.Base64)
> myMail.Attachments.Add(myAttachment)
> SmtpMail.SmtpServer = "MyMailServer"
> SmtpMail.Send(myMail)
>
>
>
> me devuelve un error al ejecutar la aplicacion ::
> could not acces 'CDO.Message' Object
> si alqguien sabe como hacerlo bien por favor respondame



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida