0

In my outlook I have different Mail Boxes, my own and the one of my departament. I want to send emails from my department address and I am doing it by using the property .SentOnBehalfOfName. I do this from excel and I have office 2010.

Although the emails are being received by the recipients from my department address, those emails are stuck in my personal outbox (like waiting to be sent...). This becomes a problem when the number of emails I send is bigger than 30 because I reach the memory space limit.

Anybody knows how to avoid these emails stuck in my personal outbox?

This is the code I use to send emails:

Sub MandaMail(destinatarios As String, copia As String, subject As String, strbody As String, Optional CO As String = "")

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next

With OutMail
    .To = destinatarios
    .CC = copia
    .BCC = CO
    .subject = subject
    .HTMLBody = strbody 
    .SentOnBehalfOfName = "mydeparmentemail@mycompany.es"
    .send    
End With

On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

Thanks in advance

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Dani LA
  • 107
  • 1
  • 7
  • Just to be clear: Can you tie it down to `.SentOnBehalfOfName` for sure? Does it work without, or do they get stuck as well? – Pᴇʜ Jan 25 '19 at 08:07
  • 1
    See Eugene's reply in https://stackoverflow.com/questions/33331320/set-sentonbehalfofname-on-every-email-sent – Siddharth Rout Jan 25 '19 at 08:16
  • Are you sending the same email 30 times or 30 recipients in one Mail? –  Jan 25 '19 at 09:43
  • @Pᴇʜ If I dont use `.SentOnBehalfOfName` the mail is sent from my account and dont get stuck in my outbox. – Dani LA Jan 25 '19 at 11:56
  • @TanmayGawankar I am sending 30 different emails to 30 different recipients – Dani LA Jan 25 '19 at 12:00
  • @SiddharthRout I have seen it but i don't see how can I use it to solve my problem. Please could you tell me what should I look in that answer? – Dani LA Jan 25 '19 at 12:04
  • @DLA What SiddharthRout was asking for is: Are you using an Exchange Server to send these emails? If not, you cannot use `.SentOnBehalfOfName` and should try `.SendUsingAccount` instead. – Pᴇʜ Jan 25 '19 at 12:22
  • @Pᴇʜ I think my company uses Exange Server. I only was able to send emails from my departamento account while using `.SentOnBehalfOfName`. I test some codes to see if I had access to different accounts. I mean, if I use `.SendUsingAccount = OutApp.Session.Accounts.Item(1)` the email is sent from my personal acc, but if I use `.SendUsingAccount = OutApp.Session.Accounts.Item(2)` it says I am out of index so I guess I cannot use that property. – Dani LA Jan 26 '19 at 09:09

0 Answers0