+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    11-11-2009
    Location
    Argentina
    MS-Off Ver
    Excel 2007
    Posts
    10

    Arrow Auto send messages issue

    I am trying to run a macro on Outlook to send a lot of messages to different parties. The macro does work but the information that I am sending for each of them is unique so each of them should get different data but some how when I run the macro, data will mixed amount parties. Lets say that party 1 should get data 1 and party 2 should get data 2 and this is not happening, party 1 is getting data 2 and party 2 is getting data 1 or someone else data but not the one that belongs to it.

    'macro
    Code:
    Public Sub SendDrafts()
    
    Dim lDraftItem As Long
    Dim myOutlook As Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Dim myFolders As Outlook.Folders
    Dim myDraftsFolder As Outlook.MAPIFolder
    
    'Send all items in the "Drafts" folder that have a "To" address filled in.
    
    'Setup Outlook
    
    Set myOutlook = Outlook.Application
    Set myNameSpace = myOutlook.GetNamespace("MAPI")
    Set myFolders = myNameSpace.Folders
    
    'Set Draft Folder.  This will need modification based on where it's being run.
    
    Set myDraftsFolder = myFolders("Mailbox's name").Folders("Drafts")
    
    'Loop through all Draft Items
    i = 1
    For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1
     
        'Check for "To" address and only send if "To" is filled in.
     
        If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To)) > 0 Then
            i = i + 1
            'Send Item
            myDraftsFolder.Items.Item(lDraftItem).Display
            myDraftsFolder.Items.Item(lDraftItem).Send
            
            Start = Timer
            Do While Timer < Start + TimeValue("00:00:21")
                    j = 1
            Loop
            'I added time to see it this was causing the issue but after it, I still got the issue.
        End If
       
        If i > 50 Then
            GoTo tohere
        End If
     
    Next lDraftItem
     
    tohere:
    'Clean-up
     
    Set myDraftsFolder = Nothing
    
    Set myNameSpace = Nothing
    Set myOutlook = Nothing
    
    End Sub
    Can anyone help me please?

    MOD: please use CODE tags rather than QUOTE tags going forward... modified on this occasion for you.
    Last edited by DonkeyOte; 01-14-2010 at 03:39 AM.

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Auto send messages issue

    Maybe I'm missing something but there's nothing that I can see in your code that determines the actual content of each mail item .... and it is seemingly the content that is your concern, no ?

  3. #3
    Registered User
    Join Date
    11-11-2009
    Location
    Argentina
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Auto send messages issue

    I am running an access data base with another macro to uploaded all emails to draft folder, then once I have all emails in draft forder I run this macro and there is when data gets mix.

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Auto send messages issue

    I'm afraid you've lost me... all your code is doing is iterating the mail items in your Draft folder and mailing them if there's an address stipulated in the To field... what is actually in the email itself has nothing to do with the code you have posted.

    Perhaps someone else can help as I'm drawing a blank I'm afraid.

  5. #5
    Registered User
    Join Date
    11-09-2008
    Location
    germany
    Posts
    74

    Re: Auto send messages issue

    facuse currently the code you have posted is the code in Outlook. This code only checks if there is a TO in the choosen folder and then sends it.

    Getting out my crystal ball what you are doing here is generating emails in Access. and putting them all in one folder.
    Then to avoid Microsofts inability to do get things right (Unavoidable Security Messages) you are sending them from outlook.

    The data1 and party 2 choice is not in the code you have posted it is in the Access code that generates these emails.

    If you are still having problems you need to post that code.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0