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
 
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
 
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.
 
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
 
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
 
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
 
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.
Similar threads
Thread starter Title 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
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
U Disable "Always ask before opening" Dialog Using Outlook 3
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 Using Outlook 0
Diane Poremsky Always Load an Outlook Addin Using Outlook 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
L Outlook inbox is "always in front". How to stop that? BCM (Business Contact Manager) 1
D Why does BCM not always load when I restart Outlook? BCM (Business Contact Manager) 1
B Attachment.PathName is always blank Outlook VBA and Custom Forms 7
Q Otlk 2007 does not block when in "always prompt for..." mode Outlook VBA and Custom Forms 2
S Mailbox is always full Using Outlook 2
Q sending mail when Otlook in 'always prompt for user name and passw Outlook VBA and Custom Forms 4
P Inspector.WordEditor always returns null Outlook VBA and Custom Forms 3
C Synchronization and taking forever to send Using Outlook 2
D Send on behalf of does not store the base mailbox Using Outlook 0
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
TomHuckstep Remove Send/Receive All Folders (IMAP/POP) button from Outlook 365 Ribbon Using Outlook 2
J Macro to send email as alias Outlook VBA and Custom Forms 0
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
T Outlook 2010 recipient no longer shows in 'Send To' Using Outlook 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
L How to avoid issues with "Send on Behalf" Using Outlook 3
M Outlook 365 refuses to send email Using Outlook 0
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0

Similar threads

Back
Top