私は多くの質問を検索しましたが、私がしようとしているものに一致するものを見つけることができませんでした。送信者の名前を持つvba Outlookの署名
このOutlookコードでは、Pedidos
というメールを電子メールで送信しています。
Sub Mail_ActiveSheet()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim sCC As String
Dim Signature As String
sCC = Range("copia").Value
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
Sheets("Pedidos").Copy
Set Destwb = ActiveWorkbook
' Determine the Excel version, and file extension and format.
With Destwb
If Val(Application.Version) < 12 Then
' For Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
' For Excel 2007-2010, exit the subroutine if you answer
' NO in the security dialog that is displayed when you copy
' a sheet from an .xlsm file with macros disabled.
If Sourcewb.Name = .Name Then
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "You answered NO in the security dialog."
Exit Sub
Else
Select Case Sourcewb.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select
End If
End If
End With
' With Destwb.Sheets(1).UsedRange
' .Cells.Copy
' .Cells.PasteSpecial xlPasteValues
' .Cells(1).Select
' End With
' Application.CutCopyMode = False
' Save the new workbook, mail, and then delete it.
TempFilePath = Environ$("temp") & "\"
TempFileName = Sourcewb.Sheets("Consulta").Range("F2:G2").Value & " " _
& IIf(Len(Day(Now)) = 1, "0" & Day(Now), Day(Now)) & IIf(Len(Month(Now)) = 1, "0" & Month(Now), Month(Now)) & Year(Now) & Hour(Now) & Minute(Now) & Second(Now)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
On Error GoTo 0
' Change the mail address and subject in the macro before
' running the procedure.
With OutMail
.to = "[email protected]"
.CC = sCC
.BCC = ""
.Subject = "[PEDIDOS 019] " & TempFileName
.HTMLBody = "<font face=""calibri"" color=""black""> Olá Natalia, <br>"
.HTMLBody = .HTMLBody & " Por favor, fazer a requisição dos pedidos em anexo. <br>" & " Obrigado!<br>" & xxxxx & "</font>"
.Attachments.Add Destwb.FullName
' You can add other files by uncommenting the following statement.
'.Attachments.Add ("C:\test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
.SEND
End With
On Error GoTo 0
.Close SaveChanges:=False
End With
' Delete the file after sending.
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
あなたが見ることができるように、以下の行でxxxxx
は、私は(私が送信していたように)私の電子メールを取得し、そこにそれを書く(または名前と姓)にしたい私の署名を表します。
.HTMLBody = "<font face=""calibri"" color=""black""> Olá Natalia, <br>"
.HTMLBody = .HTMLBody & " Por favor, fazer a requisição dos pedidos em anexo. <br>" & " Obrigado!<br>" & xxxxx & "</font>"
だから私このxxxxx
は、たとえば、私の名前多分私-メール、またはすることが本当に何を。
私はすでにMailItem.SenderNameのプロパティをチェックしましたが、使用方法がわかりませんでした。これはVBAを使用した初めての電子メールですので、どんな提案も高く評価されます。
Outlookには常に新しいメッセージが表示されます。 –
@ScottHoltzmanいいえ、私が欲しい唯一の署名は、送信者の名前またはアドレスです。 – paulinhax
[この回答](https://stackoverflow.com/questions/26519325/how-to-get-the-email-address-of - 現在ログインしているユーザ)は、現在のユーザの電子メールまたは名前を取得する方法を学習します。 –