Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sending mails using outlook object

Posted on 2003-11-27
3
Medium Priority
?
552 Views
Last Modified: 2007-12-19
i am developing an application to send mails using the outlook object. since i was getting a security alert everytime the mails were sent, i downloaded and used the Redemption.dll library and safe mail objects.

i have pasted the code below:

Set myItem = CreateObject("Redemption.SafeMailItem")
Set oitem = oOutlookApplication.CreateItem(olMailItem)
strToAddress = olInboxItems_ItemAdd(myITems(intcnt))
myItem.Item = oitem
myItem.Recipients.Add (strToAddress)
myItem.Recipients.ResolveAll
myItem.Subject = "test"
myItem.Body = "this is a test"

the problem with this code is that the mails are sent to the draft folder and not the outbox. i found out why this is happening. it is because there is no email address in "sent by". i am not able to assign a sent by email address using redemption. so what is the solution to this?
0
Comment
Question by:RTKVSNL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 9831424
Try this see if this solve your problem:

Private Sub Command4_Click()
    Dim iOutlook As Outlook.Application
    Dim myApp As Outlook.MailItem
    Set iOutlook = New Outlook.Application
    Set myApp = iOutlook.CreateItem(olMailItem)
    temp = "username"
    txtMessage = "Hello World Again!"
    AttachFile = "C:\test\test.gif"
    myApp.To = "receiver@domain.com"
    myApp.Subject = "Hello World!"
    myApp.Attachments.Add AttachFile
    myApp.Body = "Hi " & temp & vbCrLf & vbCrLf & txtMessage
    myApp.Send
    Do While iOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox).Items.Count <> 0
        DoEvents
    Loop
    MsgBox "Successfully Sent", vbInformation, "Email Sent"
End Sub
0
 

Author Comment

by:RTKVSNL
ID: 9831520
this cannot solve my problem because outlook has a security patch that needs a response from the user every time a mail will be sent. that is why i am using the redemption object.
0
 
LVL 7

Accepted Solution

by:
wsteegmans earned 500 total points
ID: 9831878
Take a look at these links:
- http://www.dimastr.com/redemption/
- http://www.outlookforum.com/t36290-s 

Included, some code that creates a Auto Reply for every new message in the Inbox ...
This example uses Outlook Redemption

Sub RedemptionMail()

Dim oOutlook As Outlook.Application
Dim oFldr As Outlook.MAPIFolder
Dim oMsg, oReply As Redemption.SafeMailItem
Dim mSender As Redemption.AddressEntry
Dim mSendQue As Redemption.MAPIUtils
Dim oMessage As Object
Dim oNs As Outlook.NameSpace
Dim mSubject, mFrom, mBody As String

Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI")
Set oFldr = oNs.PickFolder
Set oMsg = CreateObject("Redemption.SafeMailItem")
Set oReply = CreateObject("Redemption.SafeMailItem")
Set mSendQue = CreateObject("Redemption.MAPIUtils")

oMsg.AuthKey = "*******"
oReply.AuthKey = "*******"
mSendQue.AuthKey = "*******"

For Each oMessage In oFldr.Items
    oMsg.Item = oMessage
    oReply.Item = oMessage.Reply ' •¤• Create reply to original message •¤•
    oReply.Body = "Testing Auto Reply"
    oReply.Send
    mSubject = oMsg 'Get e-mail subject
    mFrom = oMsg.SenderName 'Get e-mail SendersName
    Set mSender = oMsg.Sender
    mFromAdd = mSender.Address
    mBody = oMsg.Body 'Get e-mail message body
Next oMessage

mSendQue.DeliverNow

Set oOutlook = Nothing
Set oNs = Nothing
Set oFldr = Nothing
Set oMsg = Nothing
Set oReply = Nothing
Set mSender = Nothing
Set mSendQue = Nothing

End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question