Condividi tramite

Inserire firma impostata in Outlook in Excel (codice)

Anonimo
2023-07-13T16:36:47+00:00

Salve a tutti,

è possibile inserire una firma in excel in modo tale che ad ogni invio email esca la firma con immagine?

La firma è già impostata in Outlook.

Ho provato questo codice ma non viene visualizzata l'immagine.. il testo si.

Dim xOutApp As Outlook.Application

Dim xMailOut As Outlook.MailItem

Application.ScreenUpdating = False 
Set xOutApp = CreateObject("Outlook.Application")

Set xMailOut = xOutApp.CreateItem(olMailItem)

Dim OutApp As Object

Dim OutMail As Object

Dim StrMsg As String

StrMsg = "http://www.w3.org/TR/html4/strict.dtd' >"

StrMsg = "<html xmlns='http://www.w3.org/1999/xhtml'>"

StrMsg = StrMsg & "<body>"

StrMsg = StrMsg & "<br> Ti è stato assegnato un nuovo lavoro. Se hai richieste, contattaci!</body>"
StrMsg = StrMsg & "<br> Grazie di far parte del nostro team!<br>"
StrMsg = StrMsg & "</br></body></html>"Set OutApp = CreateObject("Outlook.Application")

OutApp.Session.Logon

Set OutMail = OutApp.CreateItem(0)

Dim firma As String

Dim signature As String

firma = Environ("AppData") & "\Microsoft\Signatures\Firma_professionale.htm"

If Dir(firma) <> "" Then

signature = GetBoiler(firma)     

Else         

signature = ""     

End If 
On Error Resume Next 

With OutMail 

.To = ""  
.Subject = ""  

.HTMLBody = StrMsg & signature

.Display

'.Send 

End With 

Set OutMail = Nothing 

Set OutApp = Nothing 

Set xMailOut = Nothing    

Set xOutApp = Nothing     

Application.ScreenUpdating = True

End Sub

Modulo a parte: Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.ReadAll
ts.Close End Function Grazie mille a chi mi aiuterà :)

Sol39

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento

Risposta accettata dall'autore della domanda

Anonimo
2023-07-13T17:55:17+00:00

Ciao Sol39,

è possibile inserire una firma in excel in modo tale che ad ogni invio email esca la firma con immagine?

La firma è già impostata in Outlook.

Ho provato questo codice ma non viene visualizzata l'immagine.. il testo si.

Dim xOutApp As Outlook.Application

Dim xMailOut As Outlook.MailItem



Application.ScreenUpdating = False 
Set xOutApp = CreateObject("Outlook.Application")



Set xMailOut = xOutApp.CreateItem(olMailItem)



Dim OutApp As Object



Dim OutMail As Object



Dim StrMsg As String



StrMsg = "http://www.w3.org/TR/html4/strict.dtd' >"

StrMsg = "<html xmlns='http://www.w3.org/1999/xhtml'>"

StrMsg = StrMsg & "<body>"



StrMsg = StrMsg & "<br> Ti è stato assegnato un nuovo lavoro. Se hai richieste, contattaci!</body>"
StrMsg = StrMsg & "<br> Grazie di far parte del nostro team!<br>"
StrMsg = StrMsg & "</br></body></html>"Set OutApp = CreateObject("Outlook.Application")



OutApp.Session.Logon



Set OutMail = OutApp.CreateItem(0)



Dim firma As String



Dim signature As String



firma = Environ("AppData") & "\Microsoft\Signatures\Firma_professionale.htm"



If Dir(firma) <> "" Then



signature = GetBoiler(firma)     



Else         



signature = ""     



End If 
On Error Resume Next 



With OutMail 



.To = ""  
.Subject = ""  



.HTMLBody = StrMsg & signature



.Display



'.Send 



End With 



Set OutMail = Nothing 



Set OutApp = Nothing 



Set xMailOut = Nothing    



Set xOutApp = Nothing     



Application.ScreenUpdating = True



End Sub

Modulo a parte: Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.ReadAll
ts.Close End Function

Ho anche io un problema con il tuo codice, che deriva dal codice pubblicato da Ron de Bruin.

Tuttavia, il seguente codice funziona e aggiunge la mia firma salvata in Outlook e che include un'immagine.

'========>>

Option Explicit

'-------->>

Public Sub Mail_Outlook_With_Signature_Html_1()

Dim oApp As Object 

Dim oMail As Object 

Dim strMsg As String 

Set oApp = CreateObject("Outlook.Application")

Set oMail = oApp.CreateItem(0)

strMsg = "[http://www.w3.org/TR/html4/strict.dtd](http://www.w3.org/TR/html4/strict.dtd "www.w3.org")' &gt;"   

strMsg = strMsg & "<body>"

strMsg = strMsg & "&lt;br&gt; Ti è stato assegnato un nuovo lavoro. Se hai richieste, contattaci!&lt;/body&gt;" 

strMsg = strMsg & "&lt;br&gt; Grazie di far parte del nostro team!&lt;br&gt;" 

strMsg = strMsg & "&lt;/br&gt;&lt;/body&gt;&lt;/html&gt;" 

On Error Resume Next

With oMail

    .Display 

    .To = "norman.david.jonesCHIOCCIOLAoutlook.com" 

    .CC = "" 

    .BCC = "" 

    .Subject = "Simple Signature image Test 18:40" 

    .HTMLBody = strMsg & "&lt;br&gt;" & .HTMLBody 

    .Send 

End With 

On Error GoTo 0 

Set oMail = Nothing 

Set oApp = Nothing 

End Sub

'<<========

===

Regards,

Norman

Immagine

La risposta è stata utile?

2 persone hanno trovato utile questa risposta.
0 commenti Nessun commento

3 risposte aggiuntive

Ordina per: Più utili
  1. Anonimo
    2023-07-20T07:43:13+00:00

    Ciao Sol39,

    Grazie mille Norman,

    ho risolto!

    Buona giornata :)

    Mi fa piacere che tu abbia risolto il problema e ti ringrazio per il cortese riscontro.

    Alla prossima.

    ===

    Regards,

    Norman

    Immagine

    La risposta è stata utile?

    0 commenti Nessun commento
  2. Anonimo
    2023-07-20T07:40:26+00:00

    Grazie mille Norman,

    ho risolto!

    Buona giornata :)

    Sol39

    La risposta è stata utile?

    0 commenti Nessun commento
  3. Anonimo
    2023-07-13T17:39:45+00:00

    Ciao Sol39,

    Sono Ibhadighi e sarei felice di aiutarti con la tua domanda. In questo forum, siamo consumatori Microsoft proprio come te.

    È possibile inserire una firma con un'immagine in Excel. Un modo per farlo è inserire l'immagine della tua firma direttamente nel foglio di calcolo. Puoi farlo andando alla scheda "Inserisci", facendo clic sul pulsante "Immagine" nella sezione "Illustrazioni" e sfogliando il file grafico contenente la tua firma.

    Un altro modo per inserire una firma con un'immagine in Excel consiste nell'utilizzare il codice VBA per automatizzare il processo di invio di un'e-mail da Excel con la firma di Outlook. Sembra che tu stia cercando di farlo con il codice che hai fornito. Tuttavia, sembra che il codice non faccia riferimento correttamente al percorso del file di firma. La firma di riga = Environ("AppData") & "\Microsoft\Signatures\Firma_professionale.htm" specifica il percorso del file di firma, ma potrebbe non essere corretto per il sistema. Puoi provare ad aggiornare questa riga con il percorso corretto del file della firma.

    Fateci sapere se avete bisogno di ulteriore aiuto.

    Migliori saluti IBHADIGHI

    Questa risposta è stata tradotta automaticamente. Di conseguenza, potrebbero esserci errori grammaticali o espressioni strane.

    La risposta è stata utile?

    0 commenti Nessun commento