Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Outgoing Mail Issue

    Hi Guy's, can you help with this one please ?



    I have recently changed/setup an email address to a new account

    Changed form Microsoft Exchange to IMAP/SMTP, this is for website reasons

    I have 3 accounts

    Dave@ Company A
    Accounts@ Company A
    info@ Company B

    When these were all setup with Microsoft Exchange, all worked great

    When this was Exchange, my email out account can be either of the 3 accounts

    Code:
     Set myItem = myApp.CreateItem(olMailItem)        
    Set OutAccount = myApp.Session.Accounts.Item(3) ' PROBLEM WITH USING OUT GOING MAIL SINCE CHANGING TO IMAP/SMTP ############
            With myItem
            .To = strMailTo
            .Subject = Replace(strMake & Me.txtEnq, Chr(32), Chr(8))
            .Body = strMailIn & _
            wkr & "<br>" & "<br>" & _
            User
            .SendUsingAccount = OutAccount ' PROBLEM WHEN USING INFO@ as out account
            .Display
            End With
    I can remove (3) from out account and type the email address in between quotes which then does send email from info@, however:

    selecting 3 isn't listed since change of email server

    when an email is received, it had various characters (nearly unreadable)

    I if a remove Out Account all together, email will refer to default account which i believe is correct then the email reads normal

    Is there anything you great people can advise ?

    is there something in the reference library that would fix this ?

    or

    is the only answer to refer back to Exchange Server ?

    Thank you guy's

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Even if you removed/renamed the accounts from Outlook, I doubt that they have retained the same internal pointers, as they are effectively different accounts.
    Have you examined them in VBA by looping through all the available accounts collection and printing out the account names to confirm?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi guy's

    @ Minty no, would you very kindly notch up a quick demo please ?

    I have never tried looping through account names

    ie: do i set 3 accounts in my case ?
    string the account name(s) ?
    debug for imm window to see account names ?

    unsure how to achieve this

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,942
    I have some code, but in a hospital car park at present.
    Will post it if no one else has posted by the time I get back.

    Then again, a quick google should get you the code?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    There's some complicated code here:
    https://stackoverflow.com/questions/...-through-email

    That will show you how to look at a variety of properties - use the bits you need.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,942
    Amend to suit
    Code:
    Public Function ListEMailAccounts(AcctToUSe As String) As Integer
        Dim outApp As Object
        Dim i As Integer
        Dim AccNo As Integer
        Dim emailToSendTo As String
        
        Set outApp = CreateObject("Outlook.Application")
        'emailToSendTo = "epsteel@gmail.com"                    'put required email address
        AccNo = 1
        'if smtp address=email we want to send to, acc no we are looking for is identified
        For i = 1 To outApp.Session.Accounts.Count
            'Uncomment the Debug.Print command to see all email addresses that belong to you
    'Debug.Print "Acc name: " & OutApp.Session.Accounts.Item(i) & " Acc number: " & i & " , email: " & OutApp.Session.Accounts.Item(i).SmtpAddress
            'If OutApp.Session.Accounts.Item(i).SmtpAddress = emailToSendTo Then
            If outApp.Session.Accounts.item(i).DisplayName = AcctToUSe Then
    
    
                AccNo = i
                Exit For
            End If
        Next i
        ListEMailAccounts = AccNo
        Set outApp = Nothing
    End Function
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi WGM thank you, and Minty, is the below what you mean when you always mentioned step debug ?? so it highlights the issue ?

    Click image for larger version. 

Name:	Capture.JPG 
Views:	14 
Size:	53.4 KB 
ID:	50797

  9. #9
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Also WGM, when this function you have kindly posted is changed according to my data, do i just run this from a command button and call ListEmailAccounts ?

  10. #10
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Got is WGM, hope Wales isn't as windy as the North East

    Code:
    Call ListEMailAccounts("Enter Email Address Here")
    Alt+F11 Then Ctrl+G

    Lists in Imm Window

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,942
    That code started off life as listing accounts then morphed to identifying which account to use for SendUsing.
    Just comment out what is not needed.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,942
    I would just call it from the immediate window. It is just to show you your accounts.
    If you want to use it as I last used it, then supply he name of he account.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Here is some more info, the main point is that you can use the email address to identify the account directly instead of using its index:
    https://www.rondebruin.nl/win/s1/outlook/account.htm (see the commented out line 'Set OutAccount = OutApp.Session.Accounts("ron@something.nl")).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #14
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi Vlad, thank you, yes i am aware of using the number, i always used (1) or (2) in my transport db and (3) in website db

    however since we changed from Exchange to SMTP/IMAP (3) refers back to (2), im having problems with Web db sending mails as HTML due to SMTP.IMAP which was account(3)

  15. #15
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi Guy's issue i haven't come across before, there are squares in the string (path)

    Application.FollowHyperlink strPath & strFile

    this used to open an excel file

    when i step through code, the file name is:

    Mr FirstName LastName &.xlsx

    has now become

    MrSquareFirstNameSquareLastName

    I will try and take a snip later

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 10-26-2022, 04:51 AM
  2. Mail Merge Issue with Lookup Fields
    By CycloneSteve in forum Access
    Replies: 12
    Last Post: 06-01-2021, 01:00 PM
  3. Replies: 11
    Last Post: 05-31-2017, 04:22 PM
  4. Mail Merge issue
    By johnson8809 in forum Access
    Replies: 4
    Last Post: 02-02-2015, 11:13 AM
  5. Replies: 1
    Last Post: 05-20-2009, 09:09 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