Correo en un servidor Exchange

16/04/2010 - 19:35 por Lazar | Informe spam
Hola
Access 2003 y Outlook 2003 en una Intranet con un servidor Exchange
Estoy intentando que Access envie un correo y no lo consigo, justo lanzar el
procedimiento , obtengo este error :

Error - 2147219712 [Collaboration Data Objects -
[MAPI_E_AMBIGUOUS_RECIP(80040700)]]

El código que utilizo , esta copiado de Microsoft :


'--
' This procedure sets an object variable to the MAPI Session object
' using the CreateObject() function. Then, it logs on to the session
' using a predefined profile. As soon as you are logged on,
' the procedure creates
' a new message and adds it to the Messages collection of the Outbox
' of the user. Then, it creates two recipients (one on the TO: line and
' one on the CC: line) and then adds both to the Recipients collection
' of the message. Next, it resolves the names of all recipients.
' Then, it attaches a sample file before filling in the Subject,
' Text, and Importance attributes of the message.
'--
Sub SendMAPIMessage(Destinatario As String, _
Optional ConCopia As String, _
Optional ConCopiaOculta As String, _
Optional DireccionAdjunto As String, _
Optional NombreAdjunto As String, _
Optional ElAsunto As String = "Un asunto", _
Optional ElMensaje As String = "Un cuerpo de
mensaje")

Dim MapiSession As Object
Dim MapiMessage As Object
Dim MapiRecipient As Object
Dim MapiAttachment As Object
Dim Recpt
Dim errObj As Long
Dim errMsg

On Error GoTo MAPITrap
' Create the MAPI Session.
Set MapiSession = CreateObject("Mapi.Session")

' Log on to the session. If the ProfileName argument is omitted,
' Microsoft Exchange prompts you for the profile to use. If the
' profile name is incorrect, you receive a runtime error.
MapiSession.Logon profilename:="Default Outlook Profile"
' Add a message to the Outbox.
Set MapiMessage = MapiSession.Outbox.Messages.Add

' Add the recipients of the message. Note, each recipient must be
' added separately to the Recipients collection of the Message
' object.

With MapiMessage
Set MapiRecipient = MapiMessage.Recipients.Add
MapiRecipient.Name = Destinatario
MapiRecipient.Type = mapiTo
Set MapiRecipient = MapiMessage.Recipients.Add
MapiRecipient.Name = ConCopia
MapiRecipient.Type = mapiCc
Set MapiRecipient = MapiMessage.Recipients.Add
MapiRecipient.Name = ConCopiaOculta
MapiRecipient.Type = mapiBcc

' Resolve each recipient's e-mail name.
' Starting with Outlook version 8.03 (ref. Q172623)
' OLE Messaging 1.0 was replaced with Active Messaging 1.1.
' Outlook 98 (version 8.5) replaced Active Messaging
' with Microsoft CDO (Collaborative Data Objects) 1.21.
' OLE Messaging 1.0 uses a zero-based Recipients collection;
' Active Messaging 1.1 and Microsoft CDO 1.21 are 1-based.
For Recpt = 1 To .Recipients.Count
.Recipients(Recpt).Resolve showdialog:=False
Next

' Attach a file to the message.
Set MapiAttachment = MapiMessage.Attachments.Add
With MapiAttachment
.Name = NombreAdjunto
.Type = mapiFileData
.Source = DireccionAdjunto
.ReadFromFile FileName:=DireccionAdjunto
.Position = 2880
End With

' Assign the text, subject, and importance of the message.
.Subject = ElAsunto
.Text = ElMensaje
.Importance = mapiHigh

' View the message in Microsoft Exchange before sending. Set
' the ShowDialog argument to False if you want to send the
' message without viewing it in Microsoft Exchange.
.Send showdialog:=True
End With
Set MapiSession = Nothing ' Clear the object variable.

MAPIExit:
Exit Sub

MAPITrap:
errObj = Err - vbObjectError ' Strip out the OLE automation error.
Select Case errObj
Case 275 ' User cancelled sending of message.
Resume MAPIExit
Case Else
errMsg = MsgBox("Error " & Err.Number & " " &
Err.Description)
errMsg = MsgBox("Error " & errObj & " was returned.")
Resume MAPIExit
End Select
End Sub


Gracias por la ayuda que podais prestarme

Saludos
Ramon




begin 666 Ramon.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..CM286UO;CM0:6-O#0I&3CI2
M86UO;@T*14U!24P[4%)%1CM)3E1%4DY%5#IR<&EC;VQR87)R;V)A=&5L969O
M;FEC87!U;G1O;F5T#0I2158Z,C Q,# T,394,3<S-3$S6@T*14Y$.E9#05)$
"#0H`
`
end

Preguntas similare

Leer las respuestas

#6 Lazar
23/04/2010 - 18:39 | Informe spam
Hola

Simplificando tu ejemplo me quedo esto :

Public Function EnviaAdjuntos(ByVal strPara As String, _
ByVal strRuta As Variant, _
Optional ElAsunto As String = "Recambios", _
Optional ElMensaje As String = "Ver en el
adjunto los recambios necesarios") As Boolean

Dim varMsg As Object 'Outlook.MailItem
Dim objOut As Outlook.Application
Dim strFichero As Variant
Dim lngInmediato As Long
Dim txtUsuario As String
Set objOut = New Outlook.Application
Set varMsg = objOut.CreateItem(olMailItem)
With varMsg
.To = strPara
.Subject = ElAsunto
.Body = ElMensaje
.Attachments.Add strRuta
lngInmediato = MsgBox("Envia el Correo inmediatamente " & vbCrLf &
"o prefiere " & vbCrLf & _
"Guardarlo en el Borrador " & _
vbCrLf & vbCrLf & vbCrLf & _
"Si --> Envio de correo inmediato" & vbCrLf &
"No --> Lo guarda en el Borrador", _
vbQuestion + vbYesNo, "Enviar Correo o Guardar
Correo")
If lngInmediato = vbYes Then
.Send
Else
.Save
End If
End With
EnviaAdjuntos = True
Set varMsg = Nothing
Set objOut = Nothing
End Function

En casa funciona , pero en el trabajo no


Lo mismo que esto de mas abajo, similar a tu codigo pero que en su momento
tambien probe con el mismo resultado, en casa funciona y el curro no :

Sub EnviarMensaje(Destinatario As String, _
Optional DireccionAdjunto As String, _
Optional ElAsunto As String = "Recambios", _
Optional ElMensaje As String = "Ver en el adjunto
los recambios necesarios")

Dim outApp As Outlook.Application
Dim outNsp As Outlook.Namespace
Dim olMail As Outlook.MailItem
Dim txtUsuario As String
Dim EstaFecha As Date

Set outApp = CreateObject("Outlook.Application")
Set outNsp = outApp.GetNamespace("MAPI")

outNsp.Logon
Set olMail = outApp.CreateItem(olMailItem)
olMail.To = Destinatario
olMail.Subject = ElAsunto
olMail.Attachments.Add DireccionAdjunto
olMail.Body = ElMensaje
olMail.Importance = olImportanceNormal
olMail.Send

outNsp.Logoff
Set outNsp = Nothing
Set olMail = Nothing
Set outApp = Nothing

End Sub


Gracias por tu ayuda


Saludos
Ramón



"" escribió en el mensaje
news:
En el trabajo, son un Exchange Server funciona lo que te digo.

"Lazar" escribió en el mensaje de
noticias:ezwV$4$
Hola

No si enviar un correo en condiciones normales no es el problema, de
hecho
desde el PC de casa lo hago con un procedimiento similar al que explicas
,
pero ese mismo procedimiento desde el PC del trabajo, en una
intranet y bajo un servidor Exchange , no funciona.
Buscando en Microsoft encontre lo que al parecer era el procedimiento
adecuado para Exchange:

http://support.microsoft.com/kb/153311/EN-US/

pero no soy capaz de hacerlo funcionar

Gracias
Saludos
Ramon



"" escribió en el mensaje
news:
En este artículo explico como enviar un correo desde Access (entre otras
muchas cosas)

http://juankc.spaces.live.com/blog/cns!C7F49093905E7DA2!816.entry

"Lazar" escribió en el mensaje de
noticias:#22gW#
Gracias por responder José Mª
Ya lo desactive, y lo curioso es que no hace nada, ni se para en línea
alguna , ni da error , y ni por supuesto manda el correo. Es posible
que
el fallo este en la Referencia utilizada, aunque ya he probado con
"Active Messaging 1.1" (MDISP32.TLB) y con CDO 1.21 (CDO.DLL) y en
ambos
casos hace lo mismo, no se si habrá otra mas adecuada
Gracias

Saludos
Ramón



"José Mª Fueyo" escribió en el mensaje
news:
Hola
Desactiva el control de errores, y así podrás ver en que linea
exactamente se produce el error.

Salu2
José Mª Fueyo
[MS MVP Access]

__________ Información de ESET Smart Security, versión de la base de
firmas de virus 5036 (20100417) __________

ESET Smart Security ha comprobado este mensaje.

http://www.eset.com
















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