Question

Locked

how to send e mail from a desktop application

By ramannambudiripad ·
we have developed a software which will send personalised newsletter to all our customers at scheduled time. It is a desktop application in vb.net. currently we are using mapi control and outlook express to send mail. Now i want to send this in html format please help me.
outlook express is not supporting html content
smtp mail is not working because of authentication failure
Outlook warning interrupts automated emailing

pl help me

raman nambudiripad

codes given below
'---------------------------------------------------
Private Sub SendMailMapi(byval toaddrs as string,byval subj as string, byval msg as string,byval filename as string )
Dim mps As New MSMAPI.MAPISession
Dim mpm As New MSMAPI.MAPIMessages
mps.SignOn()
mps.NewSession = True
mpm.SessionID = mps.SessionID
mpm.Compose()
mpm.RecipAddress = toaddrs
mpm.AddressResolveUI = True
mpm.MsgSubject = subj
mpm.MsgNoteText = msg
mpm.AttachmentName = FilesName
mpm.MsgType = 2
mpm.AttachmentPathName = FilesName
mpm.AttachmentType = 2
mpm.Send()
mps.SignOff()

End Sub
'-----------------------------------------------------------
Private Sub SmtpMail(byval toddrs as string,byval subj as string, byval msg as string,byval filename as string)
Dim arlAttachments As ArrayList
arlAttachments = New ArrayList()
arlAttachments.Add(New Attachment(FilesName))
Dim mailMsg As New MailMessage("mymail@mymail.com", toaddrs)
With mailMsg
.CC.Add(New MailAddress("cc@mydomain.com"))

.Subject = subj
.Body = msg
.IsBodyHtml = True
If Not IsNothing(arlAttachments) Then
Dim mailAttachment As Attachment
For Each mailAttachment In arlAttachments
.Attachments.Add(mailAttachment)
Next
End If
End With
' attempt.
Try
Dim SmtpMail As New SmtpClient("myserver.com")
SmtpMail.EnableSsl = True
SmtpMail.Port = 25
SmtpMail.UseDefaultCredentials = False
SmtpMail.Credentials = New Net.NetworkCredential("mymail@mymail.com", "mypass")
SmtpMail.Timeout = 50
SmtpMail.DeliveryMethod = SmtpDeliveryMethod.Network

SmtpMail.Send(mailMsg)

MessageBox.Show("Your email has been successfully sent!", _
"Email Send Status", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Catch exp As Exception
MessageBox.Show("The following problem occurred when attempting to " & _
"send your email: " & exp.Message, _
Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Exit Sub
End Sub
--------------------------------------------------------------------
Private Sub OutlookpMail(byval toddrs as string,byval subj as string, byval msg as string,byval filename as string)

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = toaddrs
olMail.Subject = subj
olMail.Body = msg
olMail.Send
olNS.Logoff
Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing
end sub

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums