
Como enviar email desde access con fichero adjunto
Publicado por Jorge (7 intervenciones) el 20/06/2012 12:43:31
Hola a todos.
hace tiempo consegui este codigo para poder enviar email desde access directamente sin outlook.
hasta ahora me ha ido bien, pero tengo que modificarlo para poder enviar un fichero adjunto que me solicitan.
El fichero adjunto es un informe que esta dentro de la misma base de datos de access desde donde envio el email.
Me es un poco indiferente si se hace el envio del informe directamente, casi lo prefiero, sin tener que exportarlo al disco duro.
aunque tampoco me disgusta.
Necesitaria me dijerais los mas entendidos como modificar el codigo que os doy a continuacion para poder adjuntar un informe de access al email que se envia.
Un saludo cordial y muchas gracias anticipadas...
Codigo:------------------------------------->>>>>>
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "xxxxxxxxxxxxxxxxxxxxxxx"
objMessage.From = """Email"" <[email protected]>"
objMessage.To = "[email protected]"
objMessage.BCC = "[email protected]"
objMessage.HTMLBody = "textoooooooooooooooooooo"
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.xxxx.es"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "usaurio"
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "contraseña"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
MsgBox "Mensaje Enviado Satisfactoriamente..."
Fin de codigo:....................................>>>>>>>>>>>>>>
hace tiempo consegui este codigo para poder enviar email desde access directamente sin outlook.
hasta ahora me ha ido bien, pero tengo que modificarlo para poder enviar un fichero adjunto que me solicitan.
El fichero adjunto es un informe que esta dentro de la misma base de datos de access desde donde envio el email.
Me es un poco indiferente si se hace el envio del informe directamente, casi lo prefiero, sin tener que exportarlo al disco duro.
aunque tampoco me disgusta.
Necesitaria me dijerais los mas entendidos como modificar el codigo que os doy a continuacion para poder adjuntar un informe de access al email que se envia.
Un saludo cordial y muchas gracias anticipadas...
Codigo:------------------------------------->>>>>>
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "xxxxxxxxxxxxxxxxxxxxxxx"
objMessage.From = """Email"" <[email protected]>"
objMessage.To = "[email protected]"
objMessage.BCC = "[email protected]"
objMessage.HTMLBody = "textoooooooooooooooooooo"
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.xxxx.es"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "usaurio"
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "contraseña"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
MsgBox "Mensaje Enviado Satisfactoriamente..."
Fin de codigo:....................................>>>>>>>>>>>>>>
Valora esta pregunta


0