+ Reply to Thread
Results 1 to 6 of 6

email text file - error

  1. #1
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    email text file - error

    Could someone please help me with the following error...

    I am trying to send a text file and the 1st text message goes without any problems...

    When it tries to send the 2nd message I get a debug that stops on the

    .To

    the error states that the address can not be found....I am using the same email address on both of these, if that is what is triggering the error.


    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)


    If Range("F5").Value = "Yes" Then
    With OutMail
    .To = "myemail@mydomain.com"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = GetBoiler("locationoffile\borrow.txt")
    .Send 'or use .Display
    End With
    End If

    If Range("G5").Value = "Yes" Then
    With OutMail
    .To = "myemail@mydomain.com"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = GetBoiler("locationoffile\cob.txt")
    .Send 'or use .Display
    End With
    End If


    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub


    thanks for any help

  2. #2
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Does anyone have any ideas???

    Can anyone point me in the right direction???


    thank you

    Josh

  3. #3
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845
    Josh_123456,

    Looking at you code it does not have a loop to check for another "Yes". However I modified your code.
    See if this helps.



    Please Login or Register  to view this content.
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  4. #4
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    thanks for the help Charles but how do i send more than 1

    What if I want to send an email to both parties....Based on yes in certain fields...


    Josh

  5. #5
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845
    Josh,

    Here's a site that may help.

    http://www.rondebruin.nl/sendmail.htm

    If you still need help let me know.

  6. #6
    Registered User
    Join Date
    12-05-2003
    Posts
    12
    Hi,

    I think you need to create a 2nd OutMail item as the first item has been sent.

    Try putting a second Set OutMail = OutApp.CreateItem(olMailItem) before the 2nd With Outmail commands.

    i.e.
    Set OutMail = OutApp.CreateItem(olMailItem)
    If Range("F5").Value = "Yes" Then
    With OutMail
    .To = "myemail@mydomain.com"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = GetBoiler("locationoffile\borrow.txt")
    .Display 'Send 'or use .Display
    End With
    End If

    Set OutMail = OutApp.CreateItem(olMailItem)
    If Range("G5").Value = "Yes" Then
    With OutMail
    .To = "myemail@mydomain.com"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = GetBoiler("locationoffile\cob.txt")
    .Send 'or use .Display
    End With
    End If


    Hope this helps.
    Dan

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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