Sending email from VBA (Excel) with Outlook

SaskiaHe

New Member
Joined
Apr 14, 2009
Messages
20

<button title="This question does not show any research effort; it is unclear or not useful" class="js-vote-down-btn grid--cell s-btn s-btn__unset c-pointer" aria-pressed="false" style="background-attachment: scroll; background-clip: border-box; background-color: transparent; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; border-bottom-color: currentColor; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-bottom-style: none; border-bottom-width: medium; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; border-left-color: currentColor; border-left-style: none; border-left-width: medium; border-right-color: currentColor; border-right-style: none; border-right-width: medium; border-top-color: currentColor; border-top-left-radius: 3px; border-top-right-radius: 3px; border-top-style: none; border-top-width: medium; box-shadow: none; box-sizing: inherit; color: inherit; cursor: default; display: inline-block; font-family: inherit; font-size: inherit; font-size-adjust: none; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; margin-top: 2px; outline-color: invert; outline-style: none; outline-width: medium; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: center; text-decoration: none;" aria-label="down vote" data-selected-classes="fc-theme-primary"><svg xmlns="http://www.w3.org/2000/svg" class="svg-icon m0 iconArrowDownLg" aria-hidden="true" style="box-sizing: inherit; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; vertical-align: bottom;" viewBox="0 0 36 36" width="36" height="36">
</svg></button> <button title="Click to mark as favorite question (click again to undo)" class="js-favorite-btn s-btn s-btn__unset c-pointer py8" aria-pressed="false" style="background-attachment: scroll; background-clip: border-box; background-color: transparent; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; border-bottom-color: currentColor; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-bottom-style: none; border-bottom-width: medium; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; border-left-color: currentColor; border-left-style: none; border-left-width: medium; border-right-color: currentColor; border-right-style: none; border-right-width: medium; border-top-color: currentColor; border-top-left-radius: 3px; border-top-right-radius: 3px; border-top-style: none; border-top-width: medium; box-shadow: none; box-sizing: inherit; color: inherit; cursor: default; display: inline-block; font-family: inherit; font-size: inherit; font-size-adjust: none; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: invert; outline-style: none; outline-width: medium; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: center; text-decoration: none;" aria-label="favorite" data-selected-classes="fc-yellow-600"> <svg xmlns="http://www.w3.org/2000/svg" class="svg-icon iconStar" aria-hidden="true" style="box-sizing: inherit; vertical-align: bottom;" viewBox="0 0 18 18" width="18" height="18">
</svg>
</button>


I used to send email from VBA from an Excel Workbook. This always worked correctly.Now I have a new PC and tried to run the same code. And I get a permission error. I have checked, re-checked and double checked with my old PC, but I can't find any difference in settings. Not in Excel, nor in Outlook.

Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]    

    [FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Set objOl = CreateObject("Outlook.Application")
    [/FONT]Set objMail = objOl.CreateItem(0)
    With objMail
        .Sentonbehalfofname = Sender
        .Subject = qrySubj
        .HTMLBody = "<HTML>******>" & Text & "</BODY></HTML>"
        .DeleteAfterSubmit = False
        .To = Receiver
        If Not IsMissing(When) Then .DeferredDeliveryTime = DateAdd("n", When, Now)
        .Send
    End With
[/FONT]
I tried objmail.from in stead of .
Sentonbehalfofname but then I get error 434 during execution. Property or method not being support by object.

<strike></strike>


<strike></strike><strike></strike>
 

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,711
Office Version
2016, 2013, 2011, 2010, 2007
Platform
Windows
Are you able to open outlook and send an email manually on behalf of the shared mailbox
Has your outlook profile been updated to include the shared mailbox
 

SaskiaHe

New Member
Joined
Apr 14, 2009
Messages
20
To be honest ... I'm not aware of any shared mailbox ...

On my new and old PC:
I'm using mail address xxx@bid72.com from which I can send mails with outlook.

On my old PC: when I'm trying to send mails from xxx@bid72.com with Excel/VBA and outlook, then it is using my hotmail-account to send the mails. But the bid72-address is still the sender.

On my new PC: I get the permission error when using Excel/VBA and Outlook.
 

Forum statistics

Threads
1,084,751
Messages
5,379,631
Members
401,616
Latest member
YoSquidly

Some videos you may like

This Week's Hot Topics

  • VBA code giving errors and stopping Excel
    Hello Experts, I have this code being used to loop through files in a file path, and copy specific data to another sheet. It is giving me several...
  • Disable MsgBox message
    Morning, I have a userform where if i leave a ComboBox empty i see a MsgBox warning me that i must enter an invoice number. It is this MsgBox i...
  • Macro Recorder into VBA, Copy Paste Data Filled Cells
    Hi Everyone, I have a macro recorder file that takes a selection of data, copies, then pastes into a new sheet on ("A2:B2") The issue is my...
  • Number format changes while pasting into a cell
    Hi, I am trying to paste a number 180204524303 from an email to an excel cell, however, whenever i try to do so , the the paste value appears as...
  • Collating data
    Hello all. Could someone please help. I am trying to pull all column data from multiple sheets (24 I total so far) into 1 master sheet without...
  • Sum Multiple Columns Based on Multiple Criteria
    I am trying to consolidate data by summing columns G through M based on material, plant, vendor, and fiscal year being identical. The period does...
Top