how to send email from another account (1 Viewer)


Registered User.
Jul 15, 2008
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

this lets me send an email with signature
 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") & _
    If Dir(SigString) <> "" Then
        Signature = GetBoiler(SigString)
        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
End Function
think I've got it. I had not set a reference to Outlook in the VBA editor. this is done via Tools, references

this worked at home but not at work.
anyone been able to do this if yes how did you do it please? thanks


Users who are viewing this thread

Top Bottom