Consulting

Results 1 to 6 of 6

Thread: Send recurring email from specific account

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2008
    Posts
    5
    Location

    Send recurring email from specific account

    Hi guys

    I use the macro below to send a recurring email from an Outlook To-Do List task. The email is always sent from the "default" account. How can I modify the code so that the email is sent from a different account? I believe it can be done with "SendUsingAccount" but I'm not sure how to use it. I'd be grateful if a VBA expert could help with this.

    Private Sub Application_Reminder(ByVal Item As Object)
    Dim xMailItem As MailItem
    Dim strbody As String
    On Error Resume Next
    If Item.Class <> OlObjectClass.olTask Then Exit Sub
    If Item.Categories <> "Send Recurring Email" Then Exit Sub
    Set xMailItem = Outlook.Application.CreateItem(olMailItem)
    strbody = "<font face=Verdana><font size=2>" _
    & "Weekly email event"  'Body text
    With xMailItem
    .Subject = "Weekly Email"
    .To = "thisperson-at-someisp-dot-com"
    .HTMLBody = strbody
    'Not sure how to get this to work:
    Set .SendUsingAccount = _
    Session.Accounts.Item("thatperson-at-someotherisp-dot-com") 'Account to send from.
    .Send
    End With
    Set xMailItem = Nothing
    End Sub
    Last edited by Aussiebear; 11-28-2021 at 05:12 PM. Reason: Added code tags to supplied code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •