+ Reply to Thread
Results 1 to 10 of 10

[VBA] Problem with outmail function - function sends mails only to 1 recepient

Hybrid View

sauron12 [VBA] Problem with outmail... 11-20-2015, 01:36 PM
Richard Buttrey Re: [VBA] Problem with... 11-20-2015, 01:50 PM
sauron12 Re: [VBA] Problem with... 11-20-2015, 02:04 PM
Richard Buttrey Re: [VBA] Problem with... 11-20-2015, 05:17 PM
dafer660 Re: [VBA] Problem with... 11-20-2015, 04:37 PM
sauron12 Re: [VBA] Problem with... 11-20-2015, 04:46 PM
sauron12 Re: [VBA] Problem with... 11-20-2015, 05:31 PM
Richard Buttrey Re: [VBA] Problem with... 11-20-2015, 05:57 PM
dafer660 Re: [VBA] Problem with... 11-21-2015, 11:19 AM
sauron12 Re: [VBA] Problem with... 11-21-2015, 03:30 PM
  1. #1
    Registered User
    Join Date
    11-20-2015
    Location
    Poznan
    MS-Off Ver
    Office 2007
    Posts
    5

    Re: [VBA] Problem with outmail function - function sends mails only to 1 recepient

    thanks for reply, but I need something else.
    Attachment isnt clue, code should send 3 mails, but it send only 1.

    My code is correct with sending emails - I mean:
    In folder I have 3 files:
    - 11111.pdf
    - 22222.pdf
    - 33333.pdf

    If loop find file 11111.pdf - email should be send to Receiver A (email1@email.com).
    If loop find file 22222.pdf - email should be send to Receiver B (email2@email.com)
    if loop find file 33333.pdf - email should be send to Receiver C (email3@email.com).

    But code doesnt works good. Despite I have 3 correct named files in folder - code find obiously 3 different files in pdf, but it send only one email - to receiver C, but it should send 3 different mails to 3 different email addresses.
    It's running only this part of code properly:
    PHP Code: 
    ElseIf InStr(1xFname$, "33333"vbTextCompare) > 0 Then 
                                  Temat 
    "Company 3333" 
                                  
    Tresc "ple ple 3" 
                                         
    MsgBox ("Send to company 33333"
    But in folder there is two other good files, and they should be also send to other receivers.
    Last edited by sauron12; 11-20-2015 at 02:07 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: [VBA] Problem with outmail function - function sends mails only to 1 recepient

    Hi,

    In that case I'd use something like

    Dim  stEmail As String
    
    If InStr(1, xFname$, "11111", vbTextCompare)>0 then stEmail = "email1@email.com"
    If InStr(1, xFname$, "22222", vbTextCompare)>0 then stEmail = "email2@email.com"
    If InStr(1, xFname$, "33333", vbTextCompare)>0 then stEmail = "email3@email.com"
    
    With OutMail 
         .To = stEmail 
    
    '.... etc.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Unable to send mails problem
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2015, 09:32 PM
  2. Problem in delivering the mails
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2014, 01:42 AM
  3. Set OutMail =
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2013, 10:22 AM
  4. VBS/OutMail script and macro sends email message twice
    By Andrew_Harris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2013, 08:57 PM
  5. Problem Inserting Round function into an IF function
    By Ash87 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2013, 05:37 PM
  6. Problem with deleting mails
    By Reema in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2009, 02:37 AM
  7. [SOLVED] Routing Recepient mail failure
    By asteinhoff in forum Excel General
    Replies: 0
    Last Post: 03-24-2005, 11:06 AM

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.6.0 RC 1