Specify 'From' in VBA code for outlook mail message

sariahdog

New member
Local time
Today, 06:25
Joined
May 19, 2004
Messages
9
I have an existing module that creates an outlook mail message. This works great except I can’t specify “from” in my code. I realize .from isn’t supported,

What method should I use instead of “with mailoutlook”? Below is my existing code:

Code:
Private Sub SendMailPro_Click()

    Set appoutlook = CreateObject("outlook.application")
    Set mailoutlook = appoutlook.CreateItem(olMailItem)

    
    Dim stringBody_ext As String
     
     If Me.[SS_TorP] = "P" Then
            stringBody_ext = "migration. I'll inform you of the reults on the next business day."
     Else
            stringBody_ext = "migration to SLTEST. I'll inform you of the reults on the next business day."
    End If
    With mailoutlook
     .To = Me.[SS_Sent_By]
     .Subject = "'" & Me.[SS_Excel_Name] & "' was processed successfully"
     .Body = "The spreadsheet '" & Me.[SS_Excel_Name] & _
     "' was processed and will be included in tonight's data " & stringBody_ext
     
     .Display
     End With

End Sub
 
.sender didn't work

Thanks for the suggestion, SforSoftware, but .sender isn't supported in "with mailoutlook" either.

Any other ideas?
 
I think it might be...

Code:
.SenderName
 
.SenderName worked

Thank you both for the suggestions, .SenderName does work.
I thought I was going to be forced to revert to using SendKeys!

Once again your suggestions are greatly appreciated!!
 
I thought I was going to be forced to revert to using SendKeys!

uggghhh! - never never and thrice never use sendkeys. Sendkeys are evil!
 

Users who are viewing this thread

Back
Top Bottom