Always Send from Default Account, depend of receive account

Status
Not open for further replies.

Zlatko

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Hello,
I have one problem with script "send from default address", because i need to omit this rule for gmail account.

Public Sub New_Mail()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem
For Each oAccount In Application.Session.Accounts
If oAccount = "Account Name" Then
Set oMail = Application.ActiveExplorer.Selection(1).Reply
oMail.SendUsingAccount = oAccount
oMail.Display
End If
Next
End Sub

Regards
Zlatko
 

Zlatko

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Thank you Diane, but it not working..
This is example of code for "Always reply from default address":

Public Sub New_Reply()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem

For Each oAccount In Application.Session.Accounts

If oAccount = "default_address@xxx.com" Then
Set oMail = Application.ActiveExplorer.Selection(1).Reply
oMail.SendUsingAccount = oAccount
oMail.Display
End If
Next

End Sub

I created a new button with this function, but i want to exclude default reply when I reply from gmail received mails.

Regards
Zlatko
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This seems to work ok - it checks the recipient addresses for the gmail address and replies, otherwise it sets the sending account.

Code:
Public Sub AccountSelection()
Dim oAccount As Outlook.Account
Dim objMsg As MailItem, oMail As MailItem
   
If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
Set objMsg = ActiveExplorer.Selection.Item(1)
  
For Each Recipient In objMsg.Recipients
strRecip = Recipient.Address & ";" & strRecip
Next Recipient
 
If InStr(strRecip, "me@gmail.com") = 1 Then
Set oMail = objMsg.Reply
   oMail.Display
Else
For Each oAccount In Application.Session.accounts
   If oAccount = "me@slipstick.com" Then
  Set oMail = objMsg.Reply
  oMail.SendUsingAccount = oAccount
     oMail.Display
   End If
Next

End If
End If
Set objMsg = Nothing
End Sub
if you want ot capture the reply/replyall buttons, see http://www.slipstick.com/outlook/using-gmail-master-account-reply-using-correct-account/ for the method.
[DOUBLEPOST=1428989479][/DOUBLEPOST]BTW, that code won't work if you are bcc'd on the gmail address. The gmail address needs to be in the to or cc field.
 

Zlatko

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Thank you again Diane, code is ok but script is too slow for work...need 1 min to create new mail...
Whether there is an option to speed up work? That verifies only "TO" field of received mail...

Regards
Zlatko
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
How many addresses are the messages sent to? It shouldn't take that long to check the names and create a new message - it stops when it finds a match. Oops... it doesn't stop. Try adding Exit Sub after oMail.display.
[DOUBLEPOST=1429548894][/DOUBLEPOST]Also, try changing this
InStr(strRecip, "me@gmail.com") = 1

to
InStr(strRecip, "me@gmail.com") > 0
 

Zlatko

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Dear Diane,
It's better now...but it's still take too long for create mail, about 15-20 sec.
When I reply on not-gmail message, it take about 3-5 sec for create mail.
I add "Exit Sub" and change in line "InStr( )" > 0...
Scanned messages are sent only to one recipient,

Regards
Zlatko
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Try removing
For Each Recipient In objMsg.Recipients
strRecip = Recipient.Address & ";" & strRecip
Next Recipient

change
If InStr(strRecip, "me@gmail.com") > 0 Then

to

If InStr(objMsg.To, "me@gmail.com") >0 Then

I really don't think it's going to get too much faster though.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
M Outlook 2007 always tries to send 4 messages even when Outbox is empty Using Outlook 1
K Outbox doesn't always send messages. Using Outlook 1
J wireless always allows me to send/receive emails via outlook 2007. recent move to university gives me internet access but no emails can be sent or rec Using Outlook 1
DoctorJellybean Outlook 365 doesn't always mark emails as read Using Outlook 3
Commodore Folders always closed in move/copy items dialog box Using Outlook 3
B The Outlook 2016 Profile that isn't always there Using Outlook 2
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
M Item edits doesn't always sync Using Outlook 11
Diane Poremsky How to Always Process Mail After Business Hours New Slipstick.com Articles 0
Diane Poremsky Always Load an Outlook Addin New Slipstick.com Articles 1
M Always Enabled Outlook VBA and Custom Forms 3
R Coming from Thunderbird: "Always prefer display name over message header" Using Outlook 1
W Filter condition "contains"/"doesn't contain" doesn't always work Using Outlook 10
B Add-in "always enabled" but Outlook 13 won't open Using Outlook 7
C Reports always ask 'Would you like to save your changes?' BCM (Business Contact Manager) 1
T In Outlook 2013, must downloaded pictures in an email always be retained? Using Outlook 8
2 How to use outlook 2003 calendar in always offline mode Using Outlook 0
L Oulook always "disconnected" how do I keep it open all of the time? Using Outlook 1
S Please help! -- Linked Account field at Business Contacts tab is always empty BCM (Business Contact Manager) 1
J Rule does not always work Using Outlook 6
B Outlook 2003: Meeting Organizer will be set as always free or busy status Using Outlook 1
R OL2010; How to ALWAYS Reply/Forward using HTML? Using Outlook 1
D Outlook 2010 - Calendar - always show 4 weeks in month view Using Outlook 3
J Custom Forms Don't Always Auto-Forward From Public Folder Using Outlook 0
C outlook 2003 always not remove temp copy of opened attachments in temporary fo Using Outlook 4
H Arrows blue and purple not always visible Using Outlook 0
S New Mail message, with attachment, always on top. Using Outlook 7
S External e-mail attachments always seen as inline attachments with Exchange 2010 Exchange Server Administration 2
D Photos on incoming messages are tiny and my outgoing signature photo always sends to big Using Outlook 3
H Attachment dialog box "Always do this action" greyed out Using Outlook 4
L When I click on links within Outlook they always go to my website's homepage instead of going to the correct url. Using Outlook 2
J Oulook 2007 Vs. Exchange 2010...always asked about login validation... Exchange Server Administration 9
K Outlook 2010 on Exchange - 'Sent Items' box always empty on client, but populated in OWA Using Outlook 5
K Outlook 2010 w/Exchange - Sent Items always empty....? Using Outlook 2
I Inbox View Always Collapses and Sets to From Using Outlook 1
S Outlook 2007 always asks for exchange credentials when I first open it. Using Outlook 1
J Mail window always restores back to the primary mail inbox Using Outlook 2
E Outlook 2010 always focused as the main program in use Using Outlook 1
H How do I get bcc to always show? Using Outlook 1
T My outlook is always popping up ask for a network password for another acct that I had that the emai Using Outlook 1
A Cannot sort sent items, always displays by 'From' Using Outlook 1
L Outlook 2007, always reply in HTML Using Outlook 3
M OL2007 doesn't properly shut down. Always hangs at next restart... Using Outlook 1
V Outlook 2010 always books room tentatively - Exchange 2007 SP3 Using Outlook 1
R When I open my 2010 email program it always goes to error. I must reenter it and then I can get any new messages....any suggestions for correcting... Using Outlook 2
D Outlook 2010 - Mark Unread button isn't always in the correct state Using Outlook 4
T Searching for numbers does not always work. Using Outlook 1
T why does the name not always show when i am sending an email Using Outlook 5
L Outlook inbox is "always in front". How to stop that? BCM (Business Contact Manager) 1
Similar threads


















































Top