Send email via a certain a/c?

VbaInet,

Thank you for persevering.

The code produces error 438 'Object doesn't support property or method at line

strSender = .Accounts("SSAFA").SmtpAddress

Using intellisense entry, there is no Accounts property.

FWIW This is only for me and my charity work, and is obviously hampered by my only having 2003. In any later version it would be a doddle. If I was to offer it to any other volunteers, there are only about 8, so would not be hard giving them the template.

In work we used 2003/2007 and I created several templates that we used in my team, and we used them as workgroup templates, so only one quick update to an entry on the users system.

I really would not want you to waste anymore time on this unless this irks you and you really want to solve it.:mad: If that is the case I am more than happy to try anything you offer.:D

Thank you again.
 
There's no Accounts property as well! That's not convenient.
FWIW This is only for me and my charity work,...
That's why I'm being charitable with my time so don't worry about it :D Plus it would be beneficial to others reading your thread if we find other ways of doing it.

Get the e-mail address of SSAFA and put it here:
Code:
Public Sub SendUsingAnAccount()
    Dim otApp        As Outlook.Application
    Dim otNamespace  As Outlook.Namespace
    Dim otMail       As Outlook.MailItem
    
    Set otApp = GetObject(, "Outlook.Application")
    Set otNamespace = otApp.Session
    
    ' Create mail item in the specified account
    With otNamespace
        Set otMail = .Folders("[COLOR="blue"]e-mail address[/COLOR]").Items.Add(olMailItem)
    End With
    
    ' Compose and send mail
    With otMail
        .To = "gasman@swansea.co.uk"
        .SentOnBehalfOfName = "[COLOR="Blue"]e-mail address[/COLOR]"
        .Subject = "test"
        .Body = "test"
        .Send
    End With
    
    Set otApp = Nothing
End Sub
 
OK, as long as you are sure. Thank you.:)

It fails on

Code:
Set otMail = .Folders("**.*****.***@gmail.com").Items.Add(olMailItem)
with the attached pic.

Outllook 2003 does not have individual folders for each account as I have seen in later versions.

I have to use rules to get my mail into various folders.

BTW I found a mention of something called Click Yes on this site, which answers the security questions for me, but I still get to see the dialogue, just in case it is not me doing the automation. :D
 

Attachments

  • sendaccounts.jpg
    sendaccounts.jpg
    91.3 KB · Views: 77
Sure ;)

Ok, try the below, incrementing it each time up until the total number of accounts you have.
Code:
Set otMail = .Folders([COLOR="Blue"]1[/COLOR]).Items.Add(olMailItem)
See if it picks up your account. I'm suspecting that Index can only be numbers in 2003.

So everything is dumped into the Inbox in 2003? It's so long that I don't even remember how it was like.
 
I get 'Array index out of bounds'

I believe this is because I only have two folders (top level)
One is called Personal Folders New and the other is Archive Folders.
The first is where all my current mails are located and in subfolders like Inbox, sent Items etc and the other is the pst file where I have archived all my 2015 mail up to End of May.

On passes of 1 and 2, it used my default a/c each time, but did put the gmail address in the From field.
The order of my accounts in the list is
NtlWorld
Gmail
 
On passes of 1 and 2, it used my default a/c each time, but did put the gmail address in the From field.
The order of my accounts in the list is
NtlWorld
Gmail
That's a strange occurrence. If the From field shows the right e-mail, it should send from that e-mail.

Is there a Sender property of a MailItem object?

If I get my hands on a machine with Outlook 2003 I will have a proper look.
 
I'll hold out until I get a 2003 Outlook. If I do, I'll let you know, but obviously it' not in my list of priorities so I might be a while ;)
 
I'll hold out until I get a 2003 Outlook. If I do, I'll let you know, but obviously it' not in my list of priorities so I might be a while ;)

That is not a problem. As I said before I am more than happy with what I have at present. I even used it live today. :D

Thank you for your help and perseverance.
 

Users who are viewing this thread

Back
Top Bottom