Results 1 to 5 of 5
  1. #1
    person1 is offline Novice
    Windows 7 Access 2007
    Join Date
    Dec 2010
    Posts
    3

    Email form opens 2 emails

    Hi

    I am wondering if anyone can tell me why this form opens 2 emails?



    It creates the email addressed, with subject, with content and attachment and then it opens a blank new email.

    I didn't write it but I have been asked to fix it and I am new to Access.

    Any help appreciated.
    Regards.

    Code:
    Private Sub cmdemail_Click()
    
    On Error GoTo HandleErr:
    
    Dim myOlApp As Outlook.Application
    Dim MyItem As Outlook.MailItem
    Dim strSal As String, strName As String, strOFT As String
    
    strOFT = "\\CGICSVR\Public\BOP\BOPEmail1.oft"
    strName = "Dear " & Me!GivenName
    strSal = "<p><font face='Verdana, Arial, Helvetica, sans-serif'>" & strName & ",</font></p>"
    
    Set myOlApp = CreateObject("Outlook.Application")
    Set MyItem = myOlApp.CreateItemFromTemplate(strOFT)
    
    MyItem.To = Me!EmailAddress
    MyItem.Attachments.Add "\\CGICSVR\Public\BOP\Bank On Property.pdf"
    MyItem.HTMLBody = strSal & MyItem.HTMLBody
    MyItem.Display
    'MyItem.Send
    Me!DateSent = Format(Now, "Short Date")
    Me!Method = "Email"
    ExitHere:
        Exit Sub
    
    HandleErr:
        MsgBox Err & ": " & Err.Description
        Resume ExitHere
    
    End Sub

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    creates two emails? e.g. - it creates 2 mail items you mean?

    is one the template and the other the new mail item the code creates, I wonder?

  3. #3
    person1 is offline Novice
    Windows 7 Access 2007
    Join Date
    Dec 2010
    Posts
    3
    Quote Originally Posted by ajetrumpet View Post
    creates two emails? e.g. - it creates 2 mail items you mean?

    is one the template and the other the new mail item the code creates, I wonder?
    Yes, it creates 2 mail items. The first is the template with attachment and is addressed to the client.

    The 2nd mail item is a blank, unaddressed mail item.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    is there an option in outlook somewhere to automatically create a new message when you open the program?

    I know there is an option to do that somewhere, but I don't know what event triggers it. similar to sending automatically/deleting trash when you exit outlook...

  5. #5
    person1 is offline Novice
    Windows 7 Access 2007
    Join Date
    Dec 2010
    Posts
    3
    Any ideas? Surely someone on this forum must know

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

Similar Threads

  1. Form opens for only seconds
    By MFS in forum Programming
    Replies: 5
    Last Post: 11-04-2010, 09:33 PM
  2. Access emails
    By Gargen in forum Access
    Replies: 5
    Last Post: 08-04-2010, 01:10 PM
  3. Auto increment when the form opens
    By Lynn in forum Forms
    Replies: 13
    Last Post: 04-11-2010, 12:49 PM
  4. Form opens differently from control button
    By bdaniel in forum Programming
    Replies: 5
    Last Post: 12-29-2009, 12:38 PM
  5. Shortcut that ONLY opens Access Form
    By uneek78 in forum Forms
    Replies: 0
    Last Post: 03-30-2009, 06:52 AM

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