VBA Send Email with specific Email Account 
Author Message
 VBA Send Email with specific Email Account

Hi.
I've got OutLook 2000, with mutliple internet email account.
I would like to send some email, with a VBA macro, but with a specific
account
which is not the default account set in the Mail properties, as I can do
manually when I pick a account under the SEND button.

With the attached code, my email is sent but :
 1 -I can not choose the specific account
 2 - The FROM field is blank !!!

Any Idea ?

Thanks :

Here is the code :
   'Create our object variables

  Dim OutlookApp as Object 'Outlook.Application
  Dim MailItem as Object   'Outlook.MailItem
  Dim Recipient as Object  'Outlook.Recipient
  Dim Attachment as Object 'Outlook.Attachment

'Create the Outlook application object
   Set OutLookApp = CreateObject("Outlook.Application")
'Use the Application object to create our mail object
   Set MailItem = OutLookApp.CreateItem(0)
'Add a recipient to the mail item

'Add the subject and message body
   MailItem.Subject = "This is the subject"
   MailItem.Body = "This is the message body"

'Lets add a test file as an attachment.
'   MailItem.Attachments.add "c:\Test.txt"
'Finally, use the Send method to send the email
   MailItem.Send

'Now lets clean up our object references
   Set Attachment = Nothing
   Set Recipient = Nothing
   Set OutLookApp = Nothing



Mon, 07 Nov 2005 01:01:55 GMT  
 VBA Send Email with specific Email Account
Outlook Object Model does not allow to select an account to be used for
sending a mesage.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:
> Hi.
> I've got OutLook 2000, with mutliple internet email account.
> I would like to send some email, with a VBA macro, but with a specific
> account
> which is not the default account set in the Mail properties, as I can do
> manually when I pick a account under the SEND button.

> With the attached code, my email is sent but :
>  1 -I can not choose the specific account
>  2 - The FROM field is blank !!!

> Any Idea ?

> Thanks :

> Here is the code :
>    'Create our object variables

>   Dim OutlookApp as Object 'Outlook.Application
>   Dim MailItem as Object   'Outlook.MailItem
>   Dim Recipient as Object  'Outlook.Recipient
>   Dim Attachment as Object 'Outlook.Attachment

> 'Create the Outlook application object
>    Set OutLookApp = CreateObject("Outlook.Application")
> 'Use the Application object to create our mail object
>    Set MailItem = OutLookApp.CreateItem(0)
> 'Add a recipient to the mail item

> 'Add the subject and message body
>    MailItem.Subject = "This is the subject"
>    MailItem.Body = "This is the message body"

> 'Lets add a test file as an attachment.
> '   MailItem.Attachments.add "c:\Test.txt"
> 'Finally, use the Send method to send the email
>    MailItem.Send

> 'Now lets clean up our object references
>    Set Attachment = Nothing
>    Set Recipient = Nothing
>    Set OutLookApp = Nothing



Mon, 07 Nov 2005 01:16:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VBA - Sending email through a Specific Outlook Email Account

2. Same Email sent to multiple email accounts

3. Specifying eMail-Account when sending an Email

4. Send Email to a Specific Address via Default Email Client

5. Check a specific Email account

6. how to choose between multiple email accounts to send from

7. send email over different accounts in outlook

8. Send email via non-standard account

9. Send Email over a certain Account

10. Send Email over a certain Account

11. Email sent from another mail account

12. select eMail sending account on form although running in corporate mode

 

 
Powered by phpBB® Forum Software