473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CDO Message with gmail doesn't send attachment

2 New Member
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 12018
GazMathias
228 Recognized Expert New Member
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
vufltrn
2 New Member
Wow...Feeling pretty stupid about right now.

Worked perfectly.

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

Sometimes a fresh pair of eyes helps heaps, even for the blindingly obvious.
Oct 21 '08 #4
manokbyte
1 New Member
How to receive mails using CDO Message in VB.Net.
Jul 12 '09 #5
Angel Jonathan
1 New Member
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
12182
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): --- System.Diagnostics.Process.Start("mailto:someone@somewhere&subject=the% 20subject") ---
8
1529
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. However the compiler tells me that New MailMessage() is now obsolete and that instead I should use
5
2363
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 files) or images (bmp, gif or tiff) I can send the email messages OK but the attachments are giving me grief. Can anyone provide some code that adds attachments to web mail messages. Thanks for any help,
6
1965
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 a little but I can't seem to get it to work. It attaches the file properly, but only displays the Plain Text message, even in an HTML-capable mail client. I'm guessing it has something to do with the placement of the boundaries,
1
9277
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 report on the fly and send an email with that report as an attachment. Here is the code I have. ----------------------------------------------------------- Dim Server as string, File as string
7
13606
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 e-mail, I am using CDO.MESSAGE. When I tested the app in my local intranet IIS5.1 server, the e-mail part worked fine & even the attachment was sent along with the mail but after deploying the site at godaddy.com, when I try to send a file from my local...
4
9097
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 System.Net.Mail.SmtpClient(); System.Net.Mail.MailMessage correo = new
4
2199
by: ithinc | last post by:
Is there a method to send gmail through a xmlhttprequest?
2
7121
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 itself. With the old CDONTS.NewMail object I used in w2k, this was achieved with AttachFile (FilePath, NewFileName). There doesn't appear to be a similar function with CDO so I was wandering if anyone had found a function or a way of doing it.
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.