Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email problem (2000-SR1)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    I am trying to send automated email using the code from the Microsoft site: <!mskb=318881>Microsoft Knowledge Base Article 318881<!/mskb>
    Have most of the bugs worked out, but when I use the "CCAddress" they suggest on the "frmMail" form, it sends a copy of everyone's email (so if I send it to 46 people in the database, with myself as the CC, I get 46 copies. Any help?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email problem (2000-SR1)

    The purpose of the code from that MSKB article is to send an individual e-mail to each recipient, so if the table contains 46 e-mail addresses, 46 e-mails will be sent. If you want to send one e-mail to 46 people, the code would have to be modified. Is that what you want? (Please be aware that if you add the 46 recipients to the To: box, each of them will be able to see the names of the others.)

  3. #3
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email problem (2000-SR1)

    Yes, I am wanting to send one email (like a weekly announcement ) to all of the recipients. As it is now, it does send the email to all 46, but also sends 46 copies to the one listed in the CCAddess text box on the form.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email problem (2000-SR1)

    See the attached text file. The loop through the records now only adds the recipients, the e-mail is composed and sent after that loop.
    I added some error handling.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email problem (2000-SR1)

    Thanks for the help, Hans. When I used that code, it sent only to the first record listed in the query...?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email problem (2000-SR1)

    Try single-stepping through the code. It should loop through the recordset and add a recipient for each record.

  7. #7
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email problem (2000-SR1)

    I've had this email setup working OK now, but wondering if there is a way to make the sender be someone else (so that all of the replies would go to that 3rd party). Would that alternate sender need to be set up as an email account in Outlook on the actual sender's computer, or is there a way to trick Outlook into sending from that other person's address, even though they are not an account on the sender's computer? Do you know what I'm getting at?

  8. #8
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Email problem (2000-SR1)

    Using Outlook you can specify a reply-to address as below.

    Dim strReplyaddress as string
    strReplyaddress ="someone@somewhere.com"

    oMailItem.ReplyRecipients.Add strReplyaddress

    The message is still sent using the account of the sender, but the replyto address is the one you specify.
    Regards
    John



  9. #9
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email problem (2000-SR1)

    Thanks, John.
    I am quite the novice with code, so bear with me if you can. When I tried to compile the code you provided, I get an error with the "oMailItem" of "variable not defined"
    Here is how the first section of the code looks right now, before the Outlook session is created:
    Function SendMessages(Optional AttachmentPath)

    'Dim MyDB As Database
    'Dim MyRS As Recordset
    Dim MyDB As DAO.Database
    Dim MyRS As DAO.Recordset
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
    Dim TheAddress As String
    'this code supplied by John Hutchinson to allow the replies to go
    'to someone other than the sender, like Joe Blow
    Dim strReplyaddress As String
    strReplyaddress = "joeblow@cox.net"
    oMailItem.ReplyRecipients.Add strReplyaddress
    'from the next line on, this is the previous code
    Set MyDB = CurrentDb
    Set MyRS = MyDB.OpenRecordset("qryEMailList")
    MyRS.MoveFirst

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email problem (2000-SR1)

    In your code, the MailItem object is named objOutlookMsg instead of oMailItem, so the line becomes

    objOutlookMsg.ReplyRecipients.Add strReplyaddress

    You must place this line further down, where you set the recipients for the message. Where it is now, objOutlookMsg has not been created yet.

  11. #11
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email problem (2000-SR1)

    Thanks, Hans--that worked perfectly!

    Have a great day!

    Warren

Posting Permissions

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