For mysterious reasons I'm having problems here again. Tried to clean-up my code to be able to share it here but now I get another error and I don't know why. So this will be the precursor to my real question.
This is my (reduced) code:
Code: Select all
Sub TestMail1(Recipient As String)
Dim OLF As Object, olMailItem As Object 'Late Binding
'
Set OLF = GetObject("", "Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(6)
Set olMailItem = OLF.items.Add
'
With olMailItem
.To = Recipient
.Subject = "Test"
.Save
.Send
End With
'
Set olMailItem = Nothing
Set OLF = Nothing
End Sub
Nothing fancy as you can see. On the .Send line I get the following error however:
2024-10-10 22_08_49-Microsoft Visual Basic.png
The email does appear in the draft folder of my Outlook (classic) App however and it I manually open it there and click: "Send" it works...
I must be missing something very obvious...
FYI: "Recipient is a string with an email address (like
something@something.com). I use MS365 and Win11 Pro (all latest updates)
PS. The ultimate goal is to change the "From:" email-address (see the earlier parts in this thread). I removed these parts for now.
So I'm fine if the syntax is changed as long as that capability is still possible.
You do not have the required permissions to view the files attached to this post.