LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Help converting a macro from Outlook2007 to Excel2007

I got the following macro to finally work in Outlook. I am trying to send
from 1 specific account. I am trying to write a module that will send
invoices from excel. I have that portion working from the DEFUALT account,
but I need to send this from 1 specific business email account. It seems
that there is VERY little on how to do this on the net. Any ways, the
following code DOES work in Outlook 2007. How would I make the changes to
get it to work in Excel?
I keep getting errors on the
Set oAccount = Application.Session.Accounts(21)
I have tried making what I think would be the correct changes, but to no
avail.

Thanks
Bruce


Sub Amailtest()
Dim OutApp As Object
Dim OutNS As Object
Dim OutAcct As Object
Dim oAccount As Outlook.Account
Dim OutMail As Object
Dim EmailName As String
EmailName = "

'Get valid email account that is wanted - in this case it is the 21st
account
Set OutApp = CreateObject("Outlook.Application")
Set OutNS = OutApp.GetNamespace("MAPI")
OutNS.Logon
Set OutMail = OutApp.CreateItem(0)
Set oAccount = Application.Session.Accounts(21)
oaccountcnt = Application.Session.Accounts.count
MsgBox oAccount
MsgBox oaccountcnt


If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add EmailName
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
MsgBox oAccount
End If

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: Setting CNTL-SHIFT-F to invoke Excel2007 macro Jay Somerset Excel Discussion (Misc queries) 7 June 3rd 07 09:40 PM
HELP: Setting CNTL-SHIFT-F to invoke Excel2007 macro Jay Somerset Excel Programming 7 June 3rd 07 09:40 PM
converting Lotus 123 macro to Excell macro mark h Excel Discussion (Misc queries) 6 July 11th 05 01:28 PM
Converting XL4 Macro Sheet to VBA Geoff Martin Excel Programming 2 December 1st 04 02:25 AM
Converting to macro angelo325 Excel Programming 5 October 6th 03 06:03 PM


All times are GMT +1. The time now is 07:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"