473,408 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

CDO Message with gmail doesn't send attachment

I am trying to send an attachment using CDO message on a gmail account.

The email is sent, but it does not have the attachment.

Here is my code:
---------------------
Expand|Select|Wrap|Line Numbers
  1. Function fcnSendPage(strTo As String, AMS As String)
  2. 'Dim cdoMessage
  3.  
  4.     Set cdoMessage = CreateObject("CDO.Message")
  5.  
  6.     With cdoMessage.Configuration.Fields
  7.         .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send using the network (SMTP over the newtork)
  8.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
  9.         .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
  10.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  11.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  12.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
  13.         .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername@gmail.com"
  14.         .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
  15.         .Update
  16.     End With
  17.  
  18.     With cdoMessage
  19.         .To = strTo
  20.         .From = "myusername@gmail.com"
  21.         .TextBody = "Debrief on flight " & AMS & " has been completed."
  22.         .Send
  23.         .AddAttachment "C:\Databases\Debrief_0808-00119.rtf"
  24.         'MsgBox strTo & ": Debrief on flight " & AMS & " has been completed."
  25.     End With
  26.  
  27.     Set cdoConfig = Nothing
  28.     Set cdoMessage = Nothing
  29.  
  30. End Function
------------------------
Any thoughts?
Oct 20 '08 #1
5 11973
GazMathias
228 Expert 128KB
Expand|Select|Wrap|Line Numbers
  1. .Send
  2. .AddAttachment "C:\Databases\Debrief_0808-00119.rtf"
  3.  
Would you not add the attachment before the .Send command?

Expand|Select|Wrap|Line Numbers
  1. .AddAttachment "C:\Databases\Debrief_0808-00119.rtf"
  2. .Send
  3.  
Just a thought.
Oct 21 '08 #2
Wow...Feeling pretty stupid about right now.

Worked perfectly.

Thanks for pointing out what is now very obvious :)
Oct 21 '08 #3
GazMathias
228 Expert 128KB
No problem,

Sometimes a fresh pair of eyes helps heaps, even for the blindingly obvious.
Oct 21 '08 #4
How to receive mails using CDO Message in VB.Net.
Jul 12 '09 #5
Hi there!
I'm using vufltrn's code. I typed it as it is, but I'm getting an error while sending the email:
"Error de transporte en la conexion al servidor"

It's in spanish, it seems that there's some transport error with the connection to gmail's server.
Any ideas?
Jul 12 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Robbie De Sutter | last post by:
Hello, How do I open a new, empty e-mail message from the default e-mail client whereby the sender is given and a file is attached? Currently I use the command (vb.net): ---...
8
by: Howard | last post by:
Using visual studio 2005 I am sending an email using a vaiable Dim mail As New MailMessage() and then later setting the recipient address by mail.To = name@domain.co.uk This works fine....
5
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav...
6
by: Karl Groves | last post by:
I'm trying to work out a mail system which can send an attachment as well as an HTML formatted message (and a default plain text version). I found some pretty good code on PHP.net and modified it...
1
by: shil | last post by:
Hi, I'm using FW 2.0 to send an email with an attachment using System.Net.Mail class. If I try to attach a file from my file system, I could successfully send the eamil. But I need to generate a...
7
by: rn5a | last post by:
When a user posts a HTML Form in an ASP page, the values entered by the user in the Form are mailed to the website owner. Users can also attach a file before posting the Form. To send the...
4
by: Seguros Catatumbo | last post by:
Hi guys, i am having trouble deleting a file after sending an email. The file is in use. Here's the code: String texto = "Test"; System.Net.Mail.SmtpClient smtp = new...
4
by: ithinc | last post by:
Is there a method to send gmail through a xmlhttprequest?
2
by: Yosi | last post by:
Hi All I have recently changed my send email vbscript to work on W2K3 and I am now using the CDO.Message object. I need to rename files attached to the email without copying / renaming the file...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.