VBA EMail distribution not working

SupremeDr

New Member
Joined
Aug 15, 2019
Messages
34
Hello,
[FONT=&quot]I've built a program in excel VBA that creates emails and attaches invoices based on a distribution list.
The program creates drafts of the email and saves them for review before we manually send them.
The issue is that every single e-mail came back undeliverable.
This is the e-mail I received
-----
From: System Administrator
Sent: Thursday, August 29, 2019 2:00 PM
Subject: Undeliverable: REDACTED
Your message did not reach some or all of the intended recipients.
Subject: REDACTED
Sent: 8/29/2019 2:00 PM
The following recipient(s) cannot be reached:
REDACTED@REDACTED.COM on
The recipient has been deleted or has no email address.
-----
I can copy/paste the email addresses in just fine but for some reason this method won't work. When we reviewed the draft everything looked fine I'm very confused. (Note that after the first few emails came back we just replaced the email addresses in the drafts. We didn't create new emails)

Here is the section of code that adds the emails.

Code:
Set Mail = objOutlook.CreateItem(olMailItem)
                        Mail.To = wsMLOG.Range("L" & i).Value & ";" & wsMLOG.Range("M" & i).Value & ";" & wsMLOG.Range("N" & i).Value & ";" & wsMLOG.Range("O" & i).Value & ";" & wsMLOG.Range("P" & i).Value & ";" & wsMLOG.Range("Q" & i).Value & ";" & wsMLOG.Range("R" & i).Value & ";" & wsMLOG.Range("S" & i).Value & ";" & wsMLOG.Range("T" & i).Value & ";" & wsMLOG.Range("U" & i).Value & ";" & wsMLOG.Range("V" & i).Value & ";" & wsMLOG.Range("W" & i).Value & ";" & wsMLOG.Range("X" & i).Value & ";" & wsMLOG.Range("Y" & i).Value & ";" & wsMLOG.Range("Z" & i).Value & ";" & wsMLOG.Range("AA" & i).Value & ";" & wsMLOG.Range("AB" & i).Value
                        Mail.Subject = wsMLOG.Range("B" & i).Value & " " & wsMLOG.Range("C" & i).Value
                        Mail.Body = Sheets("Sheet1").Range("A1").Text


[/FONT]
 

SupremeDr

New Member
Joined
Aug 15, 2019
Messages
34
I have some more information on this.

I changed my code to the following
Code:
mailAddress = wsMLOG.Range("L" & i).Value & ";" & wsMLOG.Range("M" & i).Value & ";" & wsMLOG.Range("N" & i).Text & ";" & wsMLOG.Range("O" & i).Text & ";" & wsMLOG.Range("P" & i).Text & ";" & wsMLOG.Range("Q" & i).Text & ";" & wsMLOG.Range("R" & i).Text & ";" & wsMLOG.Range("S" & i).Text & ";" & wsMLOG.Range("T" & i).Text & ";" & wsMLOG.Range("U" & i).Text & ";" & wsMLOG.Range("V" & i).Text & ";" & wsMLOG.Range("W" & i).Text & ";" & wsMLOG.Range("X" & i).Text & ";" & wsMLOG.Range("Y" & i).Text & ";" & wsMLOG.Range("Z" & i).Text & ";" & wsMLOG.Range("AA" & i).Text & ";" & wsMLOG.Range("AB" & i).Text
                        Mail.To = mailAddress
                        Mail.Subject = wsMLOG.Range("B" & i).Value & " " & wsMLOG.Range("C" & i).Value & " Claims"
                        Mail.Body = Sheets("Sheet1").Range("A1").Text
I stepped through the code and this is the value
"DeltaDTest001@Google.com;;;;DeltaDTest005@Google.com;;;DeltaDTest003@Google.com;;;;;DeltaDTest002@Google.com;;;DeltaDTest004@Google.com;"

Those emails are valid but it still came back undeliverable.
 

SupremeDr

New Member
Joined
Aug 15, 2019
Messages
34
I have some more information on this.

I changed my code to the following
Code:
mailAddress = wsMLOG.Range("L" & i).Value & ";" & wsMLOG.Range("M" & i).Value & ";" & wsMLOG.Range("N" & i).Text & ";" & wsMLOG.Range("O" & i).Text & ";" & wsMLOG.Range("P" & i).Text & ";" & wsMLOG.Range("Q" & i).Text & ";" & wsMLOG.Range("R" & i).Text & ";" & wsMLOG.Range("S" & i).Text & ";" & wsMLOG.Range("T" & i).Text & ";" & wsMLOG.Range("U" & i).Text & ";" & wsMLOG.Range("V" & i).Text & ";" & wsMLOG.Range("W" & i).Text & ";" & wsMLOG.Range("X" & i).Text & ";" & wsMLOG.Range("Y" & i).Text & ";" & wsMLOG.Range("Z" & i).Text & ";" & wsMLOG.Range("AA" & i).Text & ";" & wsMLOG.Range("AB" & i).Text
                        Mail.To = mailAddress
                        Mail.Subject = wsMLOG.Range("B" & i).Value & " " & wsMLOG.Range("C" & i).Value & " Claims"
                        Mail.Body = Sheets("Sheet1").Range("A1").Text
I stepped through the code and this is the value
"DeltaDTest001@Google.com;;;;DeltaDTest005@Google.com;;;DeltaDTest003@Google.com;;;;;DeltaDTest002@Google.com;;;DeltaDTest004@Google.com;"

Those emails are valid but it still came back undeliverable.
10/10 idiot here. Used google.com instead of gmail.com. It works now (I had to change .value to .text)
 
Last edited:

Forum statistics

Threads
1,081,994
Messages
5,362,607
Members
400,684
Latest member
Vie

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top