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.
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
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
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 1
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
M I cant send emails via Outlook in my W10 PC. Using Outlook 3
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
G Send a greeting message to a contact on birthday Outlook VBA and Custom Forms 5
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
R How to restrict GWSMO sync to Outlook Send/Receive cycles Using Outlook 0
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to send from acct 2 but showing email name from acct 1 as From - alias? Using Outlook 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0

Similar threads

Top