Operating system:: Windows 11 Pro
Outlook version: Microsoft 365 V2403
Email type or host: POP
Outlook version: Microsoft 365 V2403
Email type or host: POP
Diane Poremsky helped me in 2014 to code VBA script below in order to send out batch mails for invoicing and statements.
The problem is that since about 2 months ago Outlook sends from my default account and Data file selected which is linked to my Accounting Software that generates the mails. No matter what I do and add to the VBA, the final e-mail is sent from my default account. I place a pause in the VBA to check what is saved and it even saves the correct From Account but after sent it defaults back to my default account. It seems that Outlook uses the default DATA File selection to detemine the account from which to send and not only the default email account setting? I cannot change my Default Data File as all my TASKS and links with iStore etc uses the default setting.
Sub ChangeSubject()
Dim myolApp As Outlook.Application
Dim aItem As Variant 'As Object
Set myolApp = CreateObject("Outlook.Application")
Set mail = myolApp.ActiveExplorer.CurrentFolder.Items
Dim i As Long
Dim strTemp As String
Dim intCount As Integer
On Error Resume Next
intCount = mail.Count
For i = intCount To 1 Step -1
Set aItem = mail.Item(i)
strTemp = "Add to Left Subject" & aItem.Subject & "Add to Right Subject"
aItem.Subject = strTemp
aItem.SendUsingAccount = "xyz.org.za" (added today to try solution)
aItem.SentOnBehalfOfName = "xyv.org.za" (added today to try solution)
aItem.Save
aItem.Send
Next i
Set myolApp = Nothing
End Sub
The problem is that since about 2 months ago Outlook sends from my default account and Data file selected which is linked to my Accounting Software that generates the mails. No matter what I do and add to the VBA, the final e-mail is sent from my default account. I place a pause in the VBA to check what is saved and it even saves the correct From Account but after sent it defaults back to my default account. It seems that Outlook uses the default DATA File selection to detemine the account from which to send and not only the default email account setting? I cannot change my Default Data File as all my TASKS and links with iStore etc uses the default setting.
Sub ChangeSubject()
Dim myolApp As Outlook.Application
Dim aItem As Variant 'As Object
Set myolApp = CreateObject("Outlook.Application")
Set mail = myolApp.ActiveExplorer.CurrentFolder.Items
Dim i As Long
Dim strTemp As String
Dim intCount As Integer
On Error Resume Next
intCount = mail.Count
For i = intCount To 1 Step -1
Set aItem = mail.Item(i)
strTemp = "Add to Left Subject" & aItem.Subject & "Add to Right Subject"
aItem.Subject = strTemp
aItem.SendUsingAccount = "xyz.org.za" (added today to try solution)
aItem.SentOnBehalfOfName = "xyv.org.za" (added today to try solution)
aItem.Save
aItem.Send
Next i
Set myolApp = Nothing
End Sub