Access - Ayuda por favor con codigo enviar mail outlook

 
Vista:

Ayuda por favor con codigo enviar mail outlook

Publicado por Anita (22 intervenciones) el 21/02/2018 17:57:12
Hola a tod@s

A ver si me pueden ayudar por favor, tengo una aplicacion para enviar correo electrónico usando outlook y me funciona perfectamente, pero tengo dos cuentas y no se como hacer para indicarle que use la segunda cuenta en vez de la primera que es la predeterminada.

Este es el código que me funciona

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
 
 
 
With OutMail
    .To = Destinatario_GlobES     'destinatario
    .CC = ""
    .BCC = ""
    .Subject = Asunto_GlobES    'asunto
    .Body = VTextoCorreo           'texto, cuerpo
 
    .Send
End With
 
Set OutMail = Nothing
Set OutApp = Nothing

He tratado de insertar: .SendUsingAccount pero no se cómo hacerlo pues no me acaba de funcionar así:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
 
Dim Mcuenta As Outlook.Account
Set Mcuenta = OutApp.Session.Accounts("anitacuentasec@enterprises.com")
 
 
 
 
With OutMail
    .To = Destinatario_GlobES     'destinatario
    .CC = ""
    .BCC = ""
    .Subject = Asunto_GlobES    'asunto
    .Body = VTextoCorreo           'texto, cuerpo
    .SendUsingAccount = Mcuenta
    .Send
End With
 
Set OutMail = Nothing
Set OutApp = Nothing

Les agradeceré cualquier comentario, gracias por su tiempo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder