OUTLOOK and statement .from

User avatar
sal21
PlatinumLounger
Posts: 4364
Joined: 26 Apr 2010, 17:36

OUTLOOK and statement .from

Post by sal21 »

Code: Select all

....
dim INVIATO_DA as string

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    INVIATO_DA="test"

    With Destwb
        
        On Error Resume Next
        
        With OutMail
            .From = INVIATO_DA
            'Debug.Print .From
            .To = DESTINATARIO
            'Debug.Print .To
            If CONF = "OK" Then
                .CC = _DESTINATARIO
            End If
            .BCC = ""
            .Subject = "AGGIORNATE AL " & DATA_DISP & " - AREA " & Me.AREA.Text
            .Body = TESTO_MESS
            .Attachments.Add TempFilePath1
            .Display
'.Send
            
        End With
        
        On Error GoTo 0
        
    End With
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    Set WS1 = Nothing
....

this is a part of my code to send email via vba code for excel
I have used from the first time the statement .from
... in effect i dont see intio the email the value from variable INVIATO_DA into the box "Inviato da:" (Send from in english)..
Why?

NOTE:
attached image with my scren shot of satndard email.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78561
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: OUTLOOK and statement .from

Post by HansV »

Outlook VBA doesn't let you change the From (Da) address for security reasons. You can set the SentOnBehalfOfName property; the message will show

Sent by Sal21 on behalf of ...

where ... is the name you used in the SentOnBehalfOfName property.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4364
Joined: 26 Apr 2010, 17:36

Re: OUTLOOK and statement .from

Post by sal21 »

HansV wrote:Outlook VBA doesn't let you change the From (Da) address for security reasons. You can set the SentOnBehalfOfName property; the message will show

Sent by Sal21 on behalf of ...

where ... is the name you used in the SentOnBehalfOfName property.
Only you!
This tips work fine!
:thankyou: