Consulting

Results 1 to 4 of 4

Thread: VBA outlook

  1. #1

    VBA outlook

    Is there a way to delete from excel commandbutton all messages without attachment in outbox(Outlook 2010) ? ?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,532
    Location
    Welcome to the forum!

    Yes.

    Is the server Gmail? I guess those have a deferred delivery time else they would send when Outlook opens.

  3. #3
    Let me describe from the beginning,i found and modified excel to send multiple mails to different peoples with personalized attachments

    Step 1:
    Outlook - enable Work Offline icon

    Step2:
    Create messages

    Step3:
    Run code to move messages without attachment from outbox to deleted items

    Sub Cleanmssg() 
        Dim selectedFolder As Outlook.MAPIFolder 
        Dim targetFolder As Outlook.MAPIFolder 
        Dim itms As Outlook.Items 
        Dim msg As Outlook.MailItem 
        Dim i As Long 
        Dim msgAttachs As Outlook.Attachments 
        Set selectedFolder = Outlook.GetNamespace("MAPI").PickFolder 
        If selectedFolder Is Nothing Then Exit Sub 
        Set targetFolder = Outlook.GetNamespace("MAPI").PickFolder 
        If targetFolder Is Nothing Then Exit Sub 
        Set itms = selectedFolder.Items 
        For i = itms.Count To 1 Step -1 
            If TypeName(itms.Item(i)) = "MailItem" Then 
                Set msg = itms.Item(i) 
                Set msgAttachs = msg.Attachments 
                If msgAttachs.Count <= 0 Then 
                    msg.Move targetFolder 
                End If 
            End If 
        Next i 
    End Sub


    Step4:
    Outlook - disable Work Offline icon to start sending(but messages are stuck and they can be sent when you open each and press Send button)


    Server is microsoft exchange server 2003 or 2007

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,532
    Location
    I am not sure about all that or if it is needed.

    Is the problem that you create Outlook mail, Send, but it goes to Outbox instead of sending out? If so, why not have the macro open Outlook before Send? http://www.rondebruin.nl/win/s1/outlook/openclose.htm

    Next time, please make your subject line more descriptive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •