• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Problems sending email with correct account

I have a macro that I have developed based on another users post.  I set up this macro on my machine and on another employees machine.  It basically forces an email to use a certain email account.  We have 3 accounts.  cumberland.com, gilmore.com, and our Exchange.  SBS2k is the name of our exchange server and is what we use for the outgoing smtp field.  Both this user and myself have all of these accounts listed in our exchange profile.  Both of our outlook account listings show: Gilmore (default), Cumberland, exchange (in that order).  When I send a message using Gilmore or cumberland it sends it correctly.  When he sends a message, it is only received as @gilmore.com.  If he doesn't use this macro, but rather manually creates a new message and selects account, it sends fine.  This problem is driving me crazy as I cannot find a solution.  The message in his mailbox says it was sent using Cumberland, but the recipient sees Gilmore.  Below is the Macro

Sub CreateNewMessage_Gilmore()

Dim olMessage As MailItem
Dim objFSO As New FileSystemObject
Dim objFile As TextStream
Dim strBuffer As String
Dim olkSendThroughBtn As Object
Dim olkSendAccount As Object
' Set the send-from to the Gilmore account
    'olMessage.SentOnBehalfOfName = "rclark@gilmore.com"<-- this is commented out now since I figured it isn't needed...ok?
    olMessage.Display
    Set olkSendThroughBtn = Application.ActiveInspector.CommandBars("Standard").Controls(3)
   
    ' Set the control index based on the position of the Gilmore account in the
    ' order of send through list.
    Set olkSendAccount = olkSendThroughBtn.Controls(2)
   
    olkSendAccount.Execute
0
clarkrobertj
Asked:
clarkrobertj
  • 5
  • 3
1 Solution
 
David LeeCommented:
Hi, clarkrobertj.

That looks like a macro I wrote.  I can't think of an explanation for the behavior you're describing other than having the accounts in a different sequence, but you've already ruled that out.  Let me see if I can think of a test to help determine what's going on here.
0
 
David LeeCommented:
clarkrobertj,

Sorry, I lost track of this question.  Are you still interested in pursuing a solution?
0
 
clarkrobertjAuthor Commented:
It would be nice, but... I know it is difficult, so... It is up to you.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
David LeeCommented:
Ok, let's try the code below.  It reads the selections on the Accounts pull down menu.  Follow these instructions to use this.

1.  Copy the code and paste it into Module1 in the Outlook VBA editor.
2.  Create a new message.  No need to fill in any of the fields, we just need a new message open on screen.
3.  Run the macro.  A dialog-box will pop up when it finishes showing the account choices available.  Please let me know what they are.

Sub EnumerateSendThroughButtons()
    Dim olkSendThroughBtn As Object, _
        olkButton As Object, _
        intCounter As Integer, _
        strResult As String
    Set olkSendThroughBtn = Application.ActiveInspector.CommandBars("Standard").Controls(3)
    For intCounter = 1 To olkSendThroughBtn.Controls.Count
        Set olkButton = olkSendThroughBtn.Controls.Item(intCounter)
        strResult = strResult & "Item #" & intCounter & " = " & olkButton.Caption & vbCrLf
    Next
    Set olkButton = Nothing
    Set olkSendThroughBtn = Nothing
    MsgBox strResult
End Sub
0
 
clarkrobertjAuthor Commented:
Sorry --  I got up doing other things and lost track of this. I pasted the code into module 1 as you suggested.  The following screen appears:
Item#1 = mail.gilmorefurnitureinc.com
Item#2 = &1 mail.gilmorefurnitureinc.com
Item#3 = &2 mail.cumberlandfurniture.com
Item#4 = &3 Microsoft Exchange Server
0
 
David LeeCommented:
Either of these lines

    Set olkSendAccount = olkSendThroughBtn.Controls(1)
    Set olkSendAccount = olkSendThroughBtn.Controls(2)

should send through the Gilmore account.  This line

    Set olkSendAccount = olkSendThroughBtn.Controls(3)

should send through the Cumberland account.  Does neither one work properly?
0
 
clarkrobertjAuthor Commented:
Thanks for all your help.  After I posted your last section of code I noticed that the user had over 15,000 emails in his inbox.  I also noticed that they had a similiar quantity in their deleted items and sent items folders as well.  I then archived his folders (and created an archive file of over 2.5 GB!)  Afterward, it appeard that everything was working correctly.  I am going to chaulk it up to an overloaded email account.  Regardless -- I am awarding you the points for your hard work.  Thanks!
0
 
David LeeCommented:
Wow, that's a lot of email.  Glad you got it working.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now