DanHamilton
New member
- Joined
- May 3, 2010
- Messages
- 1
- Programming Experience
- 10+
I have a simple form that sends email with attachment (small gif, about 5k) through smtp.gmail.com to a cellphone MMS address (9999999999@mms.att.net).
If I log in to Gmail and send the message and attachment manually, it comes through fine. But if I send the message and attachment from my program, the phone receives the message but not the attachment. The message in cludes a statement: "One or more of the message components have been deleted by MMS Adaptation. Either the message was too large or the components were unsuitable for your terminal."
Any idea what might be different about the attachment sent from Gmail and the one I send? The same file was used in both cases.
Here's the code...
If I log in to Gmail and send the message and attachment manually, it comes through fine. But if I send the message and attachment from my program, the phone receives the message but not the attachment. The message in cludes a statement: "One or more of the message components have been deleted by MMS Adaptation. Either the message was too large or the components were unsuitable for your terminal."
Any idea what might be different about the attachment sent from Gmail and the one I send? The same file was used in both cases.
Here's the code...
VB.NET:
[FONT="Courier New"] Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim Message As New MailMessage
Dim AttachmentFile As System.Net.Mail.Attachment
Dim Client As New SmtpClient("smtp.gmail.com")
Try
Message.From = New MailAddress(txtFrom.Text)
Message.To.Add(New MailAddress(txtTo.Text))
Message.Subject = txtSubject.Text
Message.Body = txtBody.Text
Message.IsBodyHtml = True
If File.Exists(txtAttachment.Text) Then
AttachmentFile = New Attachment(txtAttachment.Text)
Message.Attachments.Add(AttachmentFile)
Else
MsgBox("Attachment file not found")
Exit Sub
End If
Client.Port = 587
Client.EnableSsl = True
Client.Credentials = New System.Net.NetworkCredential("mygmailaccount@gmail.com", "mygmailpassword")
Client.Send(Message)
MsgBox("Message sent")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub[/FONT]
Last edited: