Results 1 to 12 of 12
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to automate sending invitation emails to some 40 people from an Access database. I am using Outlook Express which I think is limited??

    I did want to send an attachment with the email (Word Document) but don't think it's possible??????

    In addition, I cannot find how to include the send to email address name?????

    The code I am using is very basic as it will not serve a regular feature. Any ideas, thanks


    Dim varAddress As Variant, varSubject As String, varMessage As String, varname As String

    Private Sub Command0_Click()
    varSubject = "Test Only"
    varAdress = "myemail@hotmail.com"
    varMessage = "Hi to you all. Hope you are well"

    DoCmd.SendObject acSendNoObject, , , varAddress, , , varSubject, varMessage, True

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    To send another attachment than an Access object, you'd need to automate Outlook. If you search this forum for SendMail or for Outlook.Application, you'll find several examples.

    Outlook Express doesn't have an Automation interface, so you cannot control it using VBA.

    PS you may want to edit your post if the e-mail address is real, to prevent spammers from harvesting it.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oooops, many thanks Hans for alerting me to the email booboo. Unfortunately I don't use Outlook, and I thought things might be limited with Outlook Express. Just surprised there is no provision for filling the email To: field.

    However, many thanks again. Best regards

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

    DoCmd.SendObject acSendNoObject, , , varAddress, , , varSubject, varMessage, True

    varAddress will populate the To field.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for convincing me it should work, I had spelt VarAdress instead of VarAddress.

    Best regards

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    That's why you should enforce explicit declaration of variables - it will point out errors like that.
    Select Tools | Options in the Visual Basic Editor.
    Tick the check box "Require variable declaration".
    Click OK.

    When you try to run code in any Office application, you'll get a warning if there are undeclared or misspelled variables.

  7. #7
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again - done

  8. #8
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to put a line break in an email message.

    varMessage = "Hi, I trust you are well." & vbCr & "You may etc,etc

    However when the email opens there is not a carriage return line break. Can it be done? Many thanks

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try using vbCrLf.

  10. #10
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That was a quick response, trust your well. That worked!!!

    I have another question, the answer is probably no as it paases too near spamming, but I have put my recipients in a loop being derived from a table. The emails open up individually for me to send after the command:

    DoCmd.SendObject acSendNoObject, , , varAddress, , , varSubject, varMessage, True

    Is there a way to just send the emails in my loop?

    Thanks again

    Best regards

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The last argument True means that the mail message will be displayed. If you change it to False, the message will be sent directly.

    Whether it will work depends on where you're sending from. If from a "home" account, the ISP may limit the number of e-mails that can be sent within a short time.

  12. #12
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks very much Hans. I am sending them from home, so I will try and put a timer event in to slow them down. I only have 40 emails all going to people I know, so it is not doing something I shouldn't be doing. Thanks for your help again. Regards

Posting Permissions

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