I want to send an email from another account that I have access to on my pc.
I have found various bits of code from the internet but all of them send from my account so I must be doing something wrong.
I have tried this but may have put the code in the wrong place
strFrom = "account I want to use"
SentBehalfOfName = strFrom
I tried this, 4 representing the account I want to send from
.SendUsingAccount = OutApp.Session.Accounts.Item(4).
I think I am now asking for the full code to send from another account.
thank you in advance
smiler44
this lets me send an email with signature
I have found various bits of code from the internet but all of them send from my account so I must be doing something wrong.
I have tried this but may have put the code in the wrong place
strFrom = "account I want to use"
SentBehalfOfName = strFrom
I tried this, 4 representing the account I want to send from
.SendUsingAccount = OutApp.Session.Accounts.Item(4).
I think I am now asking for the full code to send from another account.
thank you in advance
smiler44
this lets me send an email with signature
Code:
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Dim strFrom As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H3><B>test</B></H3>"
' if you want to add a signature use this but you need to know the name of the signature
'Change only Mysig.htm to the name of your signature
sigString = Environ("appdata") & _
"\Microsoft\Signatures\Mysig.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
strFrom = "account I want to use"
'SentBehalfOfName = strFrom
On Error Resume Next
With OutMail
SentBehalfOfName = strFrom
.To = "recipients email address"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = strbody & "<br>" & Signature
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
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
[/code