Results 1 to 2 of 2
  1. #1
    bignate is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    47

    Question If Then statement doesn't recognise the value in combobox (sending an email)

    Hi, I have used the code below to send an email automatically when a new record has been created. However I recently added the If Then statement to the code as you can see. The problem is that the email wont send because it says "There must be at least one name or distribution list in the To Cc or Bcc box". It is most likely saying this because it doesn't recognise "IT" in the txtDeparment combobox. How can I get it to recognise IT in the department combobox? The reason I am using an If Then is because I will make it send to different email addresses depending on what is in txtDepartment by using ElseIf

    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
    .BodyFormat = olFormatRichText
    If Me.txtDepartment = "IT" Then
    .To = "my email"
    End If
    .Subject = "hi"
    .HTMLBody = "hi"
    .send
    End With



    Thanks

  2. #2
    bignate is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    47
    I solved it.
    It wasnt working because I had the code after DoCmd.GoToRecord acActiveDataObject, , acNewRec
    So the txtDepartment field was now blank

    I had to change it so that the code was before DoCmd.GoToRecord acActiveDataObject, , acNewRec

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sending A Report Via Email
    By Ka-Tet in forum Reports
    Replies: 0
    Last Post: 09-02-2013, 09:18 AM
  2. Sending Email with Delay
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 08-06-2013, 08:08 AM
  3. sending email through Access
    By crowegreg in forum Import/Export Data
    Replies: 4
    Last Post: 04-15-2012, 03:49 PM
  4. Email sending
    By Steven.Allman in forum Access
    Replies: 25
    Last Post: 06-21-2010, 09:37 AM
  5. Sending email
    By nashr1928 in forum Reports
    Replies: 8
    Last Post: 04-27-2010, 11:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums