A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Automatically send messages from Outbox



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 25th 06, 04:02 PM posted to microsoft.public.outlook.program_vba
Joel
external usenet poster
 
Posts: 48
Default Automatically send messages from Outbox

TIA:

Trying to send email after adding attachments in Outbox...the following code
producess error "item has been moved or deleted".

If I just Save the emails, all is OK but they will not be sent when I click
" Send and Receive" after attaching files through code.

What do I need to do in code to have the emails Sent in Outbox so that when
I click " Send and Receive" they will go...

Thanks,
Joel

Sub AddAttachmentToSelectedMessages()
Dim oFolder As Outlook.MAPIFolder
Dim items As Outlook.items
Dim objItem As MailItem


Set items =
Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).items

For Each objItem In items

If objItem.To = '" Then
objItem.Attachments.Add ("C:\115.xls")
objItem.Send
End If

If objItem.To = '" Then
objItem.Attachments.Add ("C:\116.xls")
objItem.Send
End If

If objItem.To = '" Then
objItem.Attachments.Add ("C:\117.xls")
objItem.Send
End If

Next
End Sub

Thanks again, Joel
Ads
  #2  
Old November 25th 06, 05:56 PM posted to microsoft.public.outlook.program_vba
Joel
external usenet poster
 
Posts: 48
Default Automatically send messages from Outbox

Hello All:

Realized bad code structu

Used If Elseif and all is OK,

Joel

"Joel" wrote:

TIA:

Trying to send email after adding attachments in Outbox...the following code
producess error "item has been moved or deleted".

If I just Save the emails, all is OK but they will not be sent when I click
" Send and Receive" after attaching files through code.

What do I need to do in code to have the emails Sent in Outbox so that when
I click " Send and Receive" they will go...

Thanks,
Joel

Sub AddAttachmentToSelectedMessages()
Dim oFolder As Outlook.MAPIFolder
Dim items As Outlook.items
Dim objItem As MailItem


Set items =
Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).items

For Each objItem In items

If objItem.To = '" Then
objItem.Attachments.Add ("C:\115.xls")
objItem.Send
End If

If objItem.To = '" Then
objItem.Attachments.Add ("C:\116.xls")
objItem.Send
End If

If objItem.To = '" Then
objItem.Attachments.Add ("C:\117.xls")
objItem.Send
End If

Next
End Sub

Thanks again, Joel

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Outlook send Outbox email automatically ebizsupp Outlook - Installation 1 October 28th 06 01:00 AM
send messages are sitting in outbox. How can I get them to leave blobby Outlook - General Queries 2 October 27th 06 04:00 AM
I can't send my messages. They end up in the outbox. moi Outlook - General Queries 0 October 15th 06 02:54 PM
I can't send messages. They stay in my outbox. Why? jbriggs Outlook - General Queries 3 October 2nd 06 05:16 AM
cannot send messages from outbox spatel Outlook - General Queries 8 May 14th 06 11:34 PM


All times are GMT +1. The time now is 08:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.