border

Miembros:
Mensajes:
Temas:
Online:

Ultimo Miembro:

 
 

Cuenta Bancaria en EEUU
  #1 (permalink)  
Antiguo 30-04-2008, 01:20:42
Gran Participación en el Foro
 
Registrado: jun 2007
Posts: 146
ThE_AsUs Valoración +2
Predeterminado Email desde outlook

Hola a todos, bueno lo q quiero es lo siguiente, q al darle click en un boton q se abra el outlook con el mail del destinatario ya ingresado y un titulo, como hago eso, me dieron este codigo q lo puse en el boton pero me sale error:

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "correo"
.cc = ""
.BCC = ""
.Subject = "Asunto del mensaje"
.Body = "Este es el texto del mensaje"

.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

me sale, "no se a definido el tipo..." en la 1ra linea nomas, como puedo hacer para q abra outlook con el mail ya escrito?? salu2 a todos
Responder Con Cita
  #2 (permalink)  
Antiguo 30-04-2008, 14:30:05
Avatar de Alella
Moderador
 
Registrado: mar 2004
Ubicación: BARCELONA - ESPAÑA
Posts: 985
Alella Valoración +2
Predeterminado Re: Email desde outlook

Hola, que tal.

Mira este post: http://www.foro.vb-mundo.com/f24/aut...de-email-8407/ (automatizar envio de email)

Ya nos contarás.
__________________
Un saludo.

Alfredo
Barcelona-España
_________________
Visual Basic
Videos Programacion
Foro Programacion
Tutoriales Programacion
Responder Con Cita
  #3 (permalink)  
Antiguo 30-04-2008, 21:34:01
Gran Participación en el Foro
 
Registrado: jun 2007
Posts: 146
ThE_AsUs Valoración +2
Predeterminado Re: Email desde outlook

Bueno gracias, del enlace saque este codigo:

Public Sub SendEMail(ByVal aSubject As String, ByVal aRecipients As String, Optional ByVal aBody As String = "", Optional ByVal aAttachments As String = "", Optional ByVal aRootPath As String = "")
'Dim myO As Outlook.Application
'Dim mobjNewMessage As Outlook.MailItem
Dim myO As Object
Dim mobjNewMessage As Object
Dim sRecipient, sAttachment, sDisplayName As String
Dim iMarker, iMarker2 As Integer

If aRecipients = "" Then
Exit Sub
End If

On Error GoTo Error_SendEMail
Set myO = CreateObject("Outlook.Application")
'Set mobjNewMessage = myO.CreateItem(olMailItem)
Set mobjNewMessage = myO.CreateItem(0)
mobjNewMessage.Subject = aSubject
mobjNewMessage.Body = aBody

Do
iMarker = InStr(1, aRecipients, ";", vbTextCompare)
If iMarker = 0 Then
sRecipient = aRecipients
Else
sRecipient = Mid(aRecipients, 1, iMarker - 1)
aRecipients = Mid(aRecipients, iMarker + 1)
End If
If Len(sRecipient) <> 0 Then mobjNewMessage.Recipients.Add sRecipient
Loop While iMarker <> 0

Do
iMarker = InStr(1, aAttachments, ";", vbTextCompare)
If iMarker = 0 Then
sAttachment = aAttachments
Else
sAttachment = Mid(aAttachments, 1, iMarker - 1)
aAttachments = Mid(aAttachments, iMarker + 1)
End If
If Len(sAttachment) <> 0 Then
iMarker2 = InStr(1, sAttachment, "***", vbTextCompare)
If iMarker2 <> 0 Then
sDisplayName = Mid(sAttachment, iMarker2 + 3)
sAttachment = aRootPath + Mid(sAttachment, 1, iMarker2 - 1)
If StrComp(Dir(sAttachment), "", vbTextCompare) <> 0 Then mobjNewMessage.Attachments.Add sAttachment, , , sDisplayName
Else
If StrComp(Dir(aRootPath + sAttachment), "", vbTextCompare) <> 0 Then mobjNewMessage.Attachments.Add aRootPath + sAttachment
End If
End If
Loop While iMarker <> 0

' mobjNewMessage.Display

If mobjNewMessage.Recipients.Count = 0 Then
MsgBox "No se envió ningún correo porque no hay ninguna dirección asignada.", vbExclamation, "Enviar Correo"
Else
mobjNewMessage.Send
End If
Exit_SendEMail:

Set mobjNewMessage = Nothing
Set myO = Nothing
Exit Sub
Error_SendEMail:
msgbox Err.Number & "- " & Err.Description
Resume Exit_SendEMail
Resume 0
End Sub
''''''''''''''''

pero me sale "429-El componente ActiveX no puede crear el objeto" y cuando le quito comentario a estas 2 lineas:
'Dim myO As Outlook.Application
'Dim mobjNewMessage As Outlook.MailItem
y las 2 sig' las pongo como comentario, me sale "No se a definido el tipo definido por el usuario", q esta mal ?? y me lo marca en esta line : myO As Outlook.Application
Responder Con Cita
  #4 (permalink)  
Antiguo 30-04-2008, 23:23:38
Buena Participación en el Foro
 
Registrado: feb 2005
Ubicación: Detras de un monitor...
Posts: 98
lee-mon-shu-pao Valoración +2
Predeterminado Re: Email desde outlook

Primero, debes tener instalado el Outlook (NO te sirve el outlook express)
Segundo, debes agregar la referencia, esto es ,
Proyecto, Referencias, y
tiquear Microsoft Outlook 99.99 Object Library.
__________________
---------------------
Ácido, pero vitamínico.

Maipú- Chile
Responder Con Cita
Respuesta


Herramientas
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Trackbacks are habilitado
Pingbacks are habilitado
Refbacks are habilitado



La franja horaria es GMT. Ahora son las 04:23:56.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
A vBSkinworks Design

Alojado en el servicio Premium de Masquewebs | Diseño mejorado por MasqueWebs

right